PHP pearls

Found this in the PHP manual:

Note: Also note that if you are embedding PHP within XML or XHTML you will need to use the <?php ?> tags to remain compliant with standards.

What?? Who cares?? I mean, this embedded PHP code is meant to be seen only by the PHP interpreter, parsed and sent back to the client as XML or XHTML, so what’s the point here?

Advertisement

One thought on “PHP pearls

  1. It has nothing to do with PHP. Processing instructions in XML data have to be well formed.

    The PHP manual is right to recommend good practices. If you like to valid your XML data when they contain PHP processing instruction.

    For the record, PHP allows both “<?" (short tag) and "<?php" as start tag. Short tags should be avoided as there is a risk to mess up either with a validation tool or with the php interpreter when it meets other "<?".

    More info about PI:
    http://www.w3.org/TR/REC-xml/#sec-pi

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s