Originally, I built my web sites with just plain HTML. To make it easier and not have to duplicate HTML I used include files to include common HTML that I had on my web sites, e.g. Google Analytics code, Copyright, internal and external links, contact information. For example, the html include syntax I used to include the common Google Analytics code was:
<!–#include virtual=”includeanalytics.html” –>
However, I wanted more functionality on my web sites, so I started using PHP 5.3 on my host (GoDaddy). When I set up PHP to run for my websites, all my includes stopped working. This is because the .html files were being interpreted by the PHP engine. To fix this, I had to use PHP include syntax, e.g.
<?php include(‘includeanalytics.html’); ?>
After using this syntax, my includes worked correctly. So, this is how to use PHP includes in HTML files.