Re: PHP code only allowed in XHTML 5?

Thomas Broyer On 09-07-23 10.23:

> On Wed, Jul 22, 2009 at 7:50 PM, Leif Halvard Silli wrote:
>> Thomas Broyer On 09-07-22 15.56:


>> Making PHP pages that are valid before execution is a choice of the author
>> or the authoring tool.
> 
> If the author has to know that:
>  - he must not use ">" (i.e. use \x3E instead) to be valid HTML 4 (and
> to comply with how Firefox and Opera will parse the doc [1])
>  - he must use paired quotes to comply with how IE will parse the doc [1]
>  - he should not output HTML that would change the way the HTML is
> parsed and alter its validity (i.e. <?php if ($foo) { echo
> "<select\x3E"; } else { echo "<select multiple\x3E"; }
> ?><option>A<option>B</select>)
>  - he must pay attention to the quote characters he uses in his PHP
> code when placed within an HTML attribute value (e.g. value="<?php
> echo "$foo $bar"; ?>" is invalid HTML)


It is not so uncommon to have to manage quote characters ...

>  - he must not use "--" in his PHP code when placed within an HTML
> comment (could be "--" in a string, or the decrement operator)


What was the link between '--' and PIs, here? I don't think '--' 
will hamper the processing of the PIs. In fact, "<?php <!-- -- 
-->"  validates, whereas "<!-- -- -->" doesn't (in HTML 4).

>  - and if he also wants his document to be valid HTML *and* valid
> XHTML (or at least well-formed XML), he must not use PHP within start
> tags (neither in the tag itself or within attribute values)
> 
> If he does know all these things, cannot it just ignore any
> warning/error regarding "<?" being invalid HTML5 ?


Would it not be better avoid the validator then? Isn't the point 
of the validating to squish bugs? Are authors supposed to think 
that "but I know better than the validator"?

 
> (I said "author" above, and not "authoring tool", because I can hardly
> imagine a tool that would do any/all of this without the author being
> involved)
> 
> [1] You could tell me that he won't open the page in a browser without
> first processing the PHP code; but then what would be the point of
> arguing that UAs do support the <? > syntax?

Absolutely. The point was to create a page that is valid before it 
is processed.
-- 
leif halvard silli

Received on Wednesday, 29 July 2009 02:05:07 UTC