[thelist] Embedding PHP in XHTML files

David Bindel dbindel at austin.rr.com
Sat May 18 22:36:01 CDT 2002

I'm just now learning PHP, but I'm having a problem on something that should
be really simple.

Here's my file, test.php:

<?xml version="1.0" encoding="iso-8859-1" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<p><?php echo("This is a test"); ?></p>

Apparently, the XML declaration on the first line (<?xml version="1.0"
encoding="iso-8859-1" ?>) is messing PHP up:

Parse error: parse error, unexpected T_STRING in c:\inetpub\wwwroot\test.php
on line 1

When I remove the XML declaration on the first line, the PHP works fine, but
I also throw out my XHTML 1.1 compliance with it.

Surely someone has run into this problem before and knows how to fix it.

Thanks in advance,
David Bindel

More information about the thelist mailing list