The easiest way to parse or run PHP code within an HTML page is to simply change the extension of the page from .html or .htm to .php.
Any regular text or HTML tags within the file will be totally ignored by PHP. Only the code contained within the PHP tags (<? ?>) will be processed by PHP.
If you have many HTML pages that contain PHP code and do not want to go through the trouble of renaming each file (although that method is preferred), you may make a change in the .htaccess file to parse all HTML files as PHP:
Open a text editor such as wordpad, notepad, nano, etc. and add the following line:
If you want to use PHP 5.4 instead of PHP 5.2, then use the following line instead:
This will specify that all files ending in .html or .htm should be parsed as PHP. Save the file as .htaccess.txt if using a text editor on a Windows machine. Upload this file to your webspace, placing it in the folder containing all the website files for the domain in question. Now rename the file to .htaccess after it has been uploaded, so the changes take effect immediately. The .htaccess file will affect all the files in the folder where the .htaccess is saved as well as all the sub-folders and sub-files.