One of the frequent complaints that I get from readers is, “I can’t get the php include function to work on my Godaddy hosted web site and their support department is no help”. Let’s face it, getting technical help from the “support department” of your web hosting company can sometime leave a whole lot to be desired.
To be fair, most of the leading hosting companies can and do answer most questions promptly and accurately. But, there are times, when it comes to technical questions, such as “the php function”, well, thats another matter completely. Even though they claim that it works great on their Linux platform, they just don’t seem to know, or at least the person you contacted, how or why it works. But, I digress, so I’ll get on with it before you pull out the rest of your hair.
The first thing that you need to do is remove this line from the page you are going to use
Remove this from your page: ?xml version=”1.0″ encoding=”iso-8859-1″? or you will get a parsing error and the php include function will not work.
Not all web pages will contain this statement so your page may not have this line. Yipeee! Now move on.
Next, you need to create a folder and name it phpinclude. Don’t argue, just do it. This is where you will store all the files that you want to include in your web site. The files stored in your phpinclude folder should have a .php extension. That means that the files should end with .php instead of .html or .txt and so on.
And now, the magic bullet
Now you need to create a .htaccess file. Open notepad and paste this directive into the page
AddHandler x-httpd-php .html .htm .cgi .php
save the file as .htaccess and close notepad. The file should look exactly like this .htaccess
Upload the phpinclude folder and the .htaccess file to the root directory of your web site. Make sure both files are in the same directory. You should now be good to go!