W3C home > Mailing lists > Public > public-html@w3.org > July 2009

Re: PHP code only allowed in XHTML 5?

From: Thomas Broyer <t.broyer@ltgt.net>
Date: Wed, 22 Jul 2009 23:45:41 +0200
Message-ID: <a9699fd20907221445q3cd0308bof264b0f1addcce06@mail.gmail.com>
To: Leif Halvard Silli <lhs@malform.no>
Cc: HTMLWG <public-html@w3.org>
On Wed, Jul 22, 2009 at 7:50 PM, Leif Halvard Silli wrote:
> What matters is that both <p> and <? > are supported with a
> predictable parsing in UAs [1].

The parsing is not predictable [2]

> Is "bogus comment" used about other things than the (specified) effect of
> "<? comment >" ? In other words, is it anything but a negative word for the
> effect of <? comment > ?

It is also triggered when "</" is followed by neither [A-Za-z>] or EOF
when the content model flag is set to the PCDATA state (§, and
when "<!" is followed by neither "--", "DOCTYPE" (case-insensitive
match) or "[CDATA[" (case-sensitive match, only if the insertion mode
is "in foreign content" and the current node is not an element in the
HTML namespace) (§

> The Live DOM viewer do not detect any comments for Firefox and Webkit. Is
> Live DOM Viewer wrong? Or do Firefox and Webkit not fulfill the spec yet?
> The way I read Live DOM Viewer, we have 3 different interpretation of <? >
> when we consider the result in the DOM (but one result if we consider result
> to the user).

Actually, three results if we consider result to the user [1].

>> You'll note that in WebKit and IE, it ends at the "?>", not the first
>> ">" (even a "-->" wouldn't end the "bogus comment" in these UAs)
> May be you are colored by your attitude here: I am unable to verify your
> claim. All I see is that IE and Webkit - in text/html mode - ends the PI at
> the first ">". In other words, I don't see the behavior that you describe.
> E.g. see this Live DOM viewer demo [2].

See this Live DOM viewer demo [1] (compare the second and first
paragraphs, in WebKit; this sample doesn't demo this behavior in IE)

>>  - HTML Tidy as explicit, limited support for ASP (<% %>), JSTE (<#
>> #>) and PHP (<?php ?> only, not the <? ?> syntax)
> Using e.g. an online version of TIDY [3], I am unable to confirm that it
> doesn't accept the <? ... ?> syntax. When configured to output XHTML, then
> it will correct <? ... > to <? ... ?>. Otherwise, it doesn't touch it. (But
> HTML Tidy is very configurable.)

So it's a documentation omission (the doc only deals with the <?php
... ?> syntax when talking about PHP)

>> Given that on the 4 main browser engines (Gecko, Trident, Presto,
>> WebKit), some parse it as a comment and others ignore it altogether
>> (and this depends on the content of the PHP code too: both IE and
>> WebKit seem to look for paired quotes with the <?php > construct);
> If you give an example, then perhaps I'll understand what you refer to
> w.r.t. IE and Webkit ...

Compare the 1st and 2nd, and 3rd and 4th paras in [1] (in IE, beware,
the third <p> is actually parsed as part of the comment from the 2nd
paragraph, so the forth <p> ends up being the third paragraph in the

>> I don't understand how you could say there is any "UA support".
> Because you can insert <? > into your code and be certain that, as long as
> you do not place another ">" in between, then UAs will not render the
> content to the user, *and* they will parse them as the W3 validator does.

Hopefully my simple example [1] proves it wrong.

> As for whether it is correct, according to HTML 4, to render <?...> as some
> kind of comment as Opera and IE do, or if it is correct to ignore them
> entirely, as Firefox/Webkit do, that I am not certain of. This is of the
> things that HTML 5 could specify.
>> (it seems like Opera 9.6 parse it as a ProcessingInstruction !?)
> Opera renders <?php > as a node named "php", and inserts the content as a
> comment, is that what you mean?

No, I mean a ProcessingInstruction node [2] (also change it to end the
PI with "?>" and notice that there's no difference). Tested in Opera

>> ...and HTML Tidy as explicit support for it besides HTML, as has been
>> suggested by others.
> Again, your interpretation of HTML Tidy seems here to be quite colored by
> your attitude to the issue - Tidy doesn't treat <?php ?> in any special way.
> You can even write <?whatever ... >.

I was confused by the documentation.

>> On Wed, Jul 22, 2009 at 1:48 PM, Leif Halvard Silli wrote:
>>> Anne van Kesteren On 09-07-22 12.53:
>>>> I agree with Simon that if you want stuff like this to work
>>>> dedicated editor support is needed (and there is to some
>>>> extent) and potentially modified validators.
>> +1 (see above, this is the case for HTML Tidy)
> Again, it isn't the case for HTML Tidy w.r.t. PI. (How it treats <% %> etc,
> is another issue.) And to repeat, once more: It is PHP and Biferno that use
> HTML syntax - not the other way around. Hence, future HTML specifications,
> such a HTML 5, are responsible for not breaking things that other languages
> and tools depends on.

PHP is text-based (byte-based actually, unfortunately), not
HTML-based. W.r.t HTML it is a *pre*processor, there's no real
relation between PHP and HTML. The fact that PHP uses a PI-like
construct is to accommodate (some) existing tools (w.r.t. XML, it
allows generating XHTML+PHP with XSLT using
<xsl:processing-instruction/> rather than <xsl:text
disable-output-escaping="yes" />)
...but that's another debate...

[1] http://software.hixie.ch/utilities/js/live-dom-viewer/saved/182
[2] http://software.hixie.ch/utilities/js/live-dom-viewer/saved/183

Thomas Broyer
Received on Wednesday, 22 July 2009 21:46:22 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:51 UTC