Page 1 of 1

PHP embeded into HTML

PostPosted: 07. August 2005 09:30
by nandoskid
Hey everyone. First of all let me say i just stumbled onto XAMPP, and i think it has so far been the best find in my conquest to learn PHP.

Anyways onto my problem ...

I am having an issue trying to run a HTML file with PHP code in it. Here is a copy of the file i created called ex3-2.htm ...

<html>
<head><title>3.2</title></head>
<body>
<h3>This part is written in HTML</h3>
<?php
echo "This was written in PHP using echo";
?>
</body>
</html>


The html portion loads up ok, but then the rest of it is blank. It's like the PHP code gets left out.

If i create a pure PHP file and load it on its own, it works fine (ex3-1.php).

I have tried to look at the text book i am learning from and there is no mention as to why the php code is being left out, even though this is an exercise i copied from a book.

If anyone can tell me what i am doing wrong, it will be much appreciated.

PostPosted: 07. August 2005 10:21
by Dave_L
In order for PHP code within a file to get interpreted, the file extension must be .php, so that Apache knows to examine the file for embedded PHP code. If you rename ex3-2.htm to ex3-2.php, then it should work correctly.

You could modify that behavior by changing the Apache configuration file httpd.conf, but that's generally not a good idea.

PostPosted: 09. August 2005 13:32
by nandoskid
Yes it has worked. I think i am following a badly written book.

Thanks for the help :)