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

Re: PHP code only allowed in XHTML 5?

From: Matthew Ratzloff <matt@builtfromsource.com>
Date: Wed, 29 Jul 2009 07:19:44 -0700
Message-ID: <3227372a0907290719y260c4513p6655ab93d0251781@mail.gmail.com>
To: public-html <public-html@w3.org>
This is such an extreme edge case that I'm surprised this discussion has
received 34 (now 35) replies.  Anyone who's validating markup is validating
the generated HTML, not the view script itself.  If one is trying to build
an PHP view script with XSLT or an XML serializer, there are better ways of
achieving that goal.
-Matt

On Wed, Jul 29, 2009 at 5:05 AM, Lachlan Hunt <lachlan.hunt@lachy.id.au>wrote:

> Daniel Glazman wrote:
>
>> Toby A Inkster wrote:
>>
>>  <p class="<?php echo 'foo';?>">
>>>
>>> Invalid in both XHTML and HTML, but perfectly legal PHP. PHP's start
>>> and end markers are not real XML processing instructions. They just
>>> look a bit like them.
>>>
>>
>> They are real processing instructions and the current PHP start marker
>> <?php was not the one early versions of PHP used. It was changed to
>> match SGML/XML PIs to allow editability in markup editors and wysiwyg
>> editors.
>>
>
> No, while it has been successfully demonstrated that the chosen syntax was
> largely inspired by PIs, PHP itself does not use either SGML or XML
> processing and, as shown multiple times in this thread, does not even fully
> conform with the syntax of either.  Pretending otherwise doesn't do anyone
> any good.
>
> Rather, PHP's use of the <?php ?> syntax (and the older <? ?> syntax) is
> simply analogous to ASP's and JSP's use of the <% %> syntax.  It's a
> distinct syntax that can be used together with HTML/XML fragments, that
> requires pre-processing in order to output either.
>
> Although, PHP certainly isn't limited to outputting just HTML or XML, it
> can output anything.  Are you concerned that the <?php ?> syntax is invalid
> in CSS, though it can quite easily be used to output CSS files like this?
>
> <?php
> header("Content-Type: text/css; charset=UTF-8");
> $mycolor = "#F63"
> ?>
> h1 { color: <?php echo $mycolor; ?>; }
> ...
>
> Why should it matter that <?php ?> is technically invalid HTML/XML, but not
> that it's also invalid CSS, JS, or any other language?
>
>  Breaking that compatibility is, IMHO, a serious error.
>>
>
> We're not breaking compatibility.  PHP never had any real compatibility, in
> the sense you are claiming, with HTML, SGML or XML.  We're just clearing up
> the fiction about PHP itself being conforming HTML, or even SGML or XML for
> that matter.
>
>
> --
> Lachlan Hunt - Opera Software
> http://lachy.id.au/
> http://www.opera.com/
>
>
Received on Wednesday, 29 July 2009 14:28:13 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC