View Full Version : Problems when using the xml declaration in a php file

01-07-2004, 05:21 AM
I tried to make my php file XHTML 1.0 Strict compatible. Doing that means I had to add this at the top of the file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

It doesn't like how the xml declaration uses the "?" that php is accustomed to. I got away with an HTML 4.0 Strict DTD, but is there an alternative to doing this for XHTML compliance?

01-07-2004, 05:37 AM
You don't actually need the <?xml prologue to be compliant; it's optional. But if you want it there are two things you can do:

You can modify your PHP config so that it requires "<?php" rather than just "<?" - I don't know the specifics of doing that though, and it may be a moot point if you can't change your server config (unless it can be done by setting a php.ini directive from .htaccess?)

Or you can write out the prologue in PHP:

<?php echo("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); ?>

01-07-2004, 05:43 AM
Thanks. I didn't know it was optional. I did know there was an alternative way of adding the character encoding but this solution would be the best out of all of them.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum