- From: Jasper Bryant-Greene <jasper@bryant-greene.name>
- Date: Fri, 24 Jun 2005 16:45:46 +1200
- To: Kelly Miller <lightsolphoenix@gmail.com>
- CC: David Woolley <david@djwhome.demon.co.uk>, www-html@w3.org
They're not really processing instructions, they just look like them so that editors and the like don't get confused. Whether you write it like that (which is inefficient anyway, because it drops in and out of PHP parsing mode) or just echo the whole tag, it's still invalid XML because it doesn't follow the correct processing instruction attr="val" structure like (<?xml version="1.0" encoding="utf-8"?>) It doesn't matter, though, because the browser never sees the PHP code, unless something's going very wrong. Jasper Kelly Miller wrote: > > 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. >> >> >
Received on Friday, 24 June 2005 04:45:05 UTC