Using XHTML and PHP

software development


I just setup my DreamHost account yesterday and today I’m trying to get a page working using an XHTML doctype and PHP directives. Because the XML doctype starts with “<?”, PHP spits out an error. I looked around on Google Groups and found that if I disable “short tags”, then I won’t get the parse error. According to, I have to edit the php.ini file to do this.

Is this something that I can do or does it have to be done for the entire server?


Nevermind, I found some more helpful info at Google Groups:

To disable the php parse short tags “<?” and use full php tags “<?php” instead, place the following in your .htaccess file in a web directory higher or at the same level as the directory (directories) you wish to affect:

php_flag short_open_tag off


How about using “<?xml” instead of “<?” to start your XHTML doctype.



SHouldn’t make a difference… If short tags are enabled, then parsing begins with “<?” regardless of whether there’s a space or character immediately following…

Take a look at; one of the recommendations is one I’ve used in a few places, namely to echo out the xml declaration, ala

echo <<<EOD

<?xml version="1.0" encoding="utf-8"?> EOD; ?>[/code]