Using XHTML and PHP

software development

#1

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 http://www.php.net/manual/en/language.basic-syntax.php, 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?


#2

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


#3

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

Frank


#4

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 http://us2.php.net/basic-syntax; one of the recommendations is one I’ve used in a few places, namely to echo out the xml declaration, ala

[code]<?php
echo <<<EOD

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