[thelist] Re: php & xhtml, escaping
David Bindel
dbindel at austin.rr.com
Wed Jul 17 22:01:01 CDT 2002
> > "The first way, <?php. . .?>, is the preferred method, as it allows
> > the use of PHP in XML-conformant code such as XHTML."
> >
> > Does this mean you must do <?php evertime or it won't validate - the
> > manual doesn't seem to go into detail about it.
>
> <?php ?> is the XML way because it describes the type of code going in
> there much like the beginning of the XHTML doctype:
>
> <?xml version="1.0" encoding="UTF-8"?>
You guys have this all wrong.....
The PHP code is executed BEFORE you validate the page, the validator never
even sees <?php ... ?>. You must use <?php ... ?> (the long form) rather
than <? ... ?> in an XHTML document so PHP doesn't mistake the XML
declaration for a PHP tag.
If you're using PHP in an XHTML make sure "short_open_tag" is set to Off in
your php.ini file. Otherwise, PHP will think the <?xml ... ?> is actually
PHP code and try to run that. What does the following so-called PHP command
do?
version="1.0" encoding="UTF-8"
IT MAKES ERRORS!
This is why you must set "short_open_tag" to Off in your php.ini file.
What it comes down to is this: if you're using PHP code in an XHTML page,
use the long method (<?php ... ?>).
If you're not, feel free to use whichever method you'd like.
HTH,
David Bindel
More information about the thelist
mailing list