Why would I want to parse PHP in HTML files?
For example let’s suppose you have dozens of html files that have the exact same navigation or footer. When you update the menu you don’t want to go and edit all the static HTML pages of your website. So you use an include that will add the menu from a PHP file, and when the menu needs to be changed you will only have to update the php file.
<?php include(“menu.php”); ?>
Sometimes, in order to use this awesome php inclusions you need to tell your apache web server that html files can have php code in them, in other words to parse php in html files. This can be achieved by adding some code to the .htaccess file. This file can be found in the www directory that will most commonly be found at this path:
If the .htaaccess file is not there, create a blank text file using your favorite text editor (mine is PSPad) and upload it to the www folder after adding the following lines in .htaccess:
AddHandler php5-script .php .html .htm
AddHandler application/x-httpd-php5 .htm .html
Make sure the filename contains the dot!
Parsing PHP In HTML when using Godaddy Hosting
Even though I prefer HostGator, I have used Godaddy’s hosting many times, and have had difficulties trying to parse PHP in HTML with Godaddy. But I have recently discovered what the contents of the .htaccess file have to be when using Godaddy:
AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php5 .php .htm .html