PHP Parse error: syntax error, unexpected T_STRING in /whatever/my-php-class.php.html on line 1 with PhpDocumentor files on CentOS

Apache LogoSymptom:

  • An XML file saved as something.php.html
  • Apache was trying to parse it as PHP and throwing an error because Short_open_tag was ‘on’

Fix:

Add the following to an .htaccess file in the folder (or a parent folder):

[cc lang=’apache’ line_numbers=’false’]php_value short_open_tag off[/cc]

I don’t know if this is a ‘bug’ or a ‘feature’. I don’t see why Apache should be interpreting *.php.html files as PHP (BAD Apache) but now that the issue is fixed for me I am not too concerned.

Update: 2010-05-07:

Kae Varens already came across this and blogged about it in October 2008. It turns out that

  1. it’s Apache – not me!
  2. there is a lot more to this than meets the eye

If you manage your own Apache web server then Kae’s blog post is required reading.

Tagged with: , , ,
Posted in Servers, Tech Blog, Web
One comment on “PHP Parse error: syntax error, unexpected T_STRING in /whatever/my-php-class.php.html on line 1 with PhpDocumentor files on CentOS
  1. Kae Verens says:

    Apache interprets it as PHP because of a stupid assumption that anything with multiple extensions must mean one of the extensions is a language. (for example, index.html.en, index.html.fr)

    It’s a security bug, but one that they refuse to fix.

    I wrote about it here: http://verens.com/2008/10/13/security-hole-for-files-with-a-dot-at-the-end/

Leave a Reply

Your email address will not be published.

*