Page 1 of 1
php code not executing
Posted: Tue Aug 03, 2010 1:02 pm
by anotherphpnoob
I am trying to use some php code inside of an html document and it does not work. I have a script.php file that executes perfectly when I try and use it. Here is the code I am currently using:
Code: Select all
<?php
echo "<title>";
echo "the Homepage!";
echo "</title>";
?>
Any suggestions would be great.
Re: php code not executing
Posted: Tue Aug 03, 2010 1:10 pm
by AbraCadaver
If the file doesn't have a .php extension then most webservers will not parse it for PHP. You can configure this, but it is normally not done by default.
Re: php code not executing
Posted: Tue Aug 03, 2010 1:18 pm
by anotherphpnoob
any good links on how i can do this?
Re: php code not executing
Posted: Tue Aug 03, 2010 1:27 pm
by AbraCadaver
Windows: right click file, select rename, delete the html or htm and type php
Linux: mv file.html file.php
Re: php code not executing
Posted: Tue Aug 03, 2010 3:02 pm
by anotherphpnoob
this is from another forum but its what i needed to know.
As for "rewriting" the page in PHP, that isn't necessary. In a PHP document, any HTML outside of the opening and closing PHP tags will get sent as normal, only PHP inside those tags will be executed.
Re: php code not executing
Posted: Tue Aug 03, 2010 3:45 pm
by AbraCadaver
anotherphpnoob wrote:this is from another forum but its what i needed to know.
As for "rewriting" the page in PHP, that isn't necessary. In a PHP document, any HTML outside of the opening and closing PHP tags will get sent as normal, only PHP inside those tags will be executed.
Yep, and they had the same name and avatar as me

Re: php code not executing
Posted: Tue Aug 03, 2010 4:46 pm
by anotherphpnoob
lol, same here obviously.