PHP coding in HTML file help (WAMP server)?

  • Thread starter Thread starter kylord123123
  • Start date Start date
K

kylord123123

Guest
I'm new to PHP coding. I've recently been using WAMP server.
Since I'm new to it, I've created a "test" folder in the www directory, and I don't have trouble creating php files, such as "index.php".

But, whenever I put PHP code into a HTML file, such as index.html, I can never get the PHP code to work. I've been using simple scripts such as:

<?php
echo "Hello, world!";
?>

It can work perfectly fine when I create the file as "index.php" and save it, but when I add HTML code (The HTML tag, header tag, body, etc.), I can never get the PHP code work. The page always appears blank.

Sample code from index.html:

<html>
<body>
<?php
echo "Hello, World!";
?>
</body>
</html>

Are there any suggestions on how I can get this to work properly?
 
php is server side. html is local. you cant put php into a local file. PHP runs on the server, alters the HTML and sends the updated document to the client.


Basically, you cant put PHP on an HTML document. It has to run on the server. Only Javascript and actionscript can run on the clients computer.
 
Back
Top