The title says it all, doesn’t it? I’ve read plenty of web articles on this, and they’re all variants of the same thing. In a nutshell, you need to create a local php.ini file and a .htaccess file. The specific file names and their respective entries will vary slightly depending on what version of PHP your hosting account is using. (There are more than 2; Some accounts use both 4 and 5.)
My hosting account runs PHP5, primarily. My .htaccess file has the entry below. Note that it doesn’t have the -cgi (as in: AddHandler x-httpd-php5-cgi) suffix.
AddHandler x-httpd-php5 .xml
My php.ini, php4.ini, and php5.ini files (yes, I have all 3) include this single line:
short_open_tag = “0″
Now files with the .xml extension will be parsed by the PHP interpreter. You’ll need to remember to manually set the content-type header of your files if they’re not HTML. In my case, I had to set the content type header to text/xml.
I had a lot of files to add the line to, plus I wanted to gzip them, so the following command came in handy: (It should all be on one line.)
find *.pdf.xml -type f -exec sed -i '1i <?php /*Some PHP Stuff*/ ?>' {} \;