Can I use PHP code snippet on a webpage with .htm or .html extension?
This works for UNIX servers with CGI protocol enabled. Running PHP code on HTM/HTML pages requires a very simple edit of the HTACCESS or Apache configuration file.
1st method:
Download .htaccess file from the root web folder and add one of the following strings:
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html
or for PHP 5 installed on the server
AddType application/x-httpd-php5 .htm
AddType application/x-httpd-php5 .html
Then upload the edited file back to the server.
2nd Method:
Your server may have a "control panel" for the virtual host where you can add the above code. The process may be slightly different, but the code is identical. If you have a control panel such as "Plesk", "C-Panel", "H-Sphere", etc. It’s very easy to do this switch right through the interface.