PHP embeded into HTML

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP embeded into HTML

Postby nandoskid » 07. August 2005 09:30

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.
nandoskid
 
Posts: 5
Joined: 07. August 2005 09:18

Postby Dave_L » 07. August 2005 10:21

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.
User avatar
Dave_L
 
Posts: 212
Joined: 23. October 2004 00:43

Postby nandoskid » 09. August 2005 13:32

Yes it has worked. I think i am following a badly written book.

Thanks for the help :)
nandoskid
 
Posts: 5
Joined: 07. August 2005 09:18


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 35 guests