RE: [PHP] comment followed by ?> fails to parse

From: Date: Wed, 29 May 2002 11:01:17 +0000
Subject: RE: [PHP] comment followed by ?> fails to parse
Groups: php.general 
Request: Send a blank email to php-general+get-99679@lists.php.net to get a copy of this message
> -----Original Message----- > From: Ed Gorski [mailto:gorskie@spjc.edu] > Sent: 28 May 2002 21:53 > > No, if you use /* ? */ as a comment the parser will skip right over > it.....if you want to use sample code in your script just use: > > /* > <? > code here.... > ?> > */ > > that'll work fine hmm, this brings up an interesting point. Whilst this is valid PHP, it is not really valid HTML and certainly not XML. Displaying a page which contains a ?> embedded in a quoted string or /* */ comment in an HTML editor which knows about XML-style <?token syntax, but not PHP specifically, may result in the PHP block apparently terminating at the embedded ?> -- this happens in, for example, Dreamweaver 4, which displays a "php", but terminates it at the *first* occurrence of ?> regardless of where that appears. The XML syntax specifies that a block starting with <?token consists of any characters not including ?>, terminating at the first occurrence of ?>. It makes no allowance for the internal syntax of any such block, so any true XML parser would also terminate a <?php block at the first ?>, regardless of other context. It would appear that if PHP wishes to be fully XML-compliant in the future, it actually needs to change so that ?> terminates a PHP block *regardless of context*. Whether such a change of behaviour is actually desirable is something the PHP community will have to decide. (Incidentally, this mirrors the HTML/JavaScript situation where you *cannot* echo the string "</script>" in one go as it terminates the <script> block. This why you sometimes see constructions such as document.write("</"+"script>")!) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#99679) next »