-1

I have created a simple web server using LAMP on Ubuntu 18.04, with PHP7 installed. The web server is only accessible by its local IP address, and can host web pages with HTML5 and CSS3, but I'm trying to integrate PHP into web pages as a stepping stone towards AJAX communication between the HTML (using JavaScript) and a back-end PHP file on the web server.

I keep getting the problem of the website body showing as:

Hello World!

";?>

with the PHP code being:

<html>
    <head>
        <title>My first PHP Website</title>
    </head>
    <body>
        <?php
            echo "<p>Hello World!</p>";
        ?>
    </body>
</html>

Does anyone know why this occurs as i would have expected the ";?> to not be displayed.

I have attached images of the code on the server (a HTML file) and the web page as seen on another computer via http://local_ip/directory/file_name.html on Google Chrome, but I also checked it on Internet Explorer and Microsoft Edge, meaning it is not just a browser issue so more likely to be a server side / code syntax issue.

Thanks in advance

  • Your server is very likely misconfigured. Can you please include the config files of your server and how you're starting it? – Aplet123 Mar 28 '20 at 14:50
  • Your server is not configured to process that file with the PHP interpreter. That's typically the default behaviour for files with *.html extension. Why don't you just name it file_name.php? – Álvaro González Mar 28 '20 at 14:51
  • In reply to Alvaro's comment, I have just tried it with php file extention and it still looks the same – Edward Drake Mar 28 '20 at 15:09

1 Answers1

-1

PHP by default processes PHP files, not html configured in your web server config.

Tom Shaw
  • 1,642
  • 2
  • 16
  • 25