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

Re: PHP code only allowed in XHTML 5?

From: Leif Halvard Silli <lhs@malform.no>
Date: Wed, 29 Jul 2009 18:29:31 +0200
Message-ID: <4A7078EB.3090006@malform.no>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
CC: Daniel Glazman <daniel.glazman@disruptive-innovations.com>, public-html <public-html@w3.org>
Lachlan Hunt On 09-07-29 14.05:

>> 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.

Said - and refuted as many times.

But until now, we have only spoken about text/html. Do you want to 
make PI illegal in XHTML also? Then here is the PHP manual [1]:

	"Note: Also note that if you are embedding PHP within XML or 
XHTML you will need to use the <?php ?> tags to remain compliant 
with standards. "

> Rather, PHP's use of the <?php ?> syntax (and the older <? ?> syntax) is 

The "old" - aka "HTML 4" - syntaxes are "<? >" and <?something >. 
The "new" syntax is compatible with the old syntax. Therefore I'll 
continue to talk about "<? >".

> 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.

ASP syntax can be enabled in PHP as well so that authors may 
choose the syntax that fits.

But it is surprising to, yet again, hear "<? ?>" (which is 
unrendered) being compared to "<% code %>" (which is rendered). It 
would be more relevant to compare "<% %>" to "[%  %]" and "{% %}". 
  And to compare "<? >" to the STYLE and the SCRIPT element.

> 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?

An answer to your question is that UAs do not render stylesheets - 
they render HTML.

>> 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.

Disagreed. But let's ignore that.  So, you are after teaching e.g. 
users of WYSIWYG tools that "<?php ?>" isn't valid HTML because it 
isn't a PI. A convoluted message.

>  We're just 
> clearing up the fiction about PHP itself being conforming HTML, or even 
> SGML or XML for that matter.

If this isn't ideology, then I don't know what ideology is. And 
neither have I seen much clearing up. HTML 5 the draft at least 

Btw, nowhere does HTML 5 say anything about PIs in SGML and XML, 
and if that is the message you want to send, then HTML is the 
wrong place.

Another question: syntax coloring.

Currently, in the syntax coloring of the VIM editor, <? > is 
treated as valid code. In fact, so is < > and <% %> as well. VIM 
has a special color - red - for invalid code. But now, with the 
proposed HTML 5 syntax, where "<? >" would be a bogus comment, how 
should it be treated in a regular syntax coloring set up?

[1] http://www.php.net/manual/en/language.basic-syntax.phpmode.php
leif halvard silli
Received on Wednesday, 29 July 2009 16:30:13 UTC

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