Is it Possible to Put PHP in a .HTML Page?

Okay, I’m a complete PHP noob, and a PHP autodidact. From my studies I htought I remembered that you can put PHP in an HTML document. I was wrong. You can put HTML in a .PHP document, but not the other way around, unless you cheat and tell your server to treat all html pages as PHP (by editing the htaccess file) you can do this by following this:

You can’t run PHP in .html files because the server does not recognize that as a valid PHP extension unless you tell it to. To do this you need to create a .htaccess file in your root web directory and add this line to it:

AddType application/x-httpd-php .htm .html

This will tell Apache to process files with a .htm or .html file extension as PHP files.

I took this bit of information from here:

Leave a Reply

Your email address will not be published. Required fields are marked *