Friday, September 18, 2009

Executing PHP code from a .html file

You can execute PHP on a .html page by adding following line in your .htaccess file :

AddType application/x-httpd-php .html

for executing PHP on a .htm page add this line instead :

AddType application/x-httpd-php .htm

The above code will make php executable on all your .html or .htm pages

If you want to make PHP executable only on one page, you may add following line in your .htaccess file:

<Files myhtmlpage.html> AddType application/x-httpd-php .html
</Files>


The above code would make PHP executable only on myhtmlpage.html and not on all html pages.

Creative Commons License