Re: XML tags are just a cheap rip-off of PHP tags

If you're not really familiar with how SGML processing instructions 
work, it's very easy to make XHTML containing PHP invalid. One common 
PHP structure is this:

<img src="<?php echo $image_fdr + "/image.jpg"; ?>" alt="<?php echo 
"This is a test image."; ?>" />

But that is invalid XML, because XML doesn't allow < and > to appear in 
attributes. Techinically, the proper way of doing it would be to make 
the whole tag echoed, but I believe there is a rule that disallows < and 
 > in processing instructions too, isn't there?

Then again, PHP processing instructions don't follow the same structure 
as XML or SGML processing instructions, either.

David Woolley wrote:

>>I don’t think it is as much a matter of stealing as that they just had 
>>to pick a delimiter character - had they used e.g. % instead of ?, the 
>>ASP and JSP folks would perhaps not have liked that.
>>    
>>
>
>I don't know the early history of PHP, but I strongly suspect that they
>use ? for the same reason that XML uses it, namely it is the proper
>way of forming an SGML processing instruction.  The name after
>the ? tells you what processor is supposed to handle that instruction,
>so there is no conflict between XML and PHP if you use properly
>formed processing instructions.
>
>For some reason, PHP also chose to allow an abbreviated form, that
>doesn't indicate the processor, so will cause conflicts, but that
>was just a convenience for pure HTML use.  It makes the resulting
>input document invalid, whereas the full form is valid SGML.
>  
>

-- 
http://www.mozilla.org/products/firefox/ - Get Firefox!
http://www.mozilla.org/products/thunderbird/ - Reclaim Your Inbox!

Received on Friday, 24 June 2005 04:35:46 UTC