|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-25 20:07 UTC] sloetz at web dot de
Hello,
I would like to suggest a small change in PHP's
handling of open tags.
I think it would be diserable to allow the use of the
short tag syntax ('<? ..?>') for documents also
containing <?xml [..] ?> tags. The increasing usage of
XML and especially XHTML (for which the <?xml..?> tag
is of course mandatory) will lead to a growing number
of collisions between PHP's syntax and user's
requirements.
AFAIK the only way for mixing xml-documents with PHP
code is to disable the short_open_tags option in the
php.ini file or make equivalent settings in the
httpd.conf (if using the Apache SAPI).
In my opinion, this is more a workaround than a real
solution. Obviously, it is impossible to include 'old'
code or third-party code which uses short tags and
even more important: not every user has access to the
php.ini file or httpd.conf file to modify the settings
accordingly.
Therefore I would like to propose to change the PHP
language scanner (as found in zend_language_scanner.l)
in a way that the token '<?xml' is not treated as a
PHP opening tag but rather (correctly) recognized as
inline HTML.
It could probably be sufficient to create an additional
rule for the scanner's <INITIAL>-start condition that
would catch the string '<?xml' before it can be
treated as an PHP open tag, e.g.:
<INITIAL>"<?xml" {
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
return T_INLINE_HTML;
}
I'm not sure whether this piece of code really works
or has unwanted side effects etc., but I guess it can put
forward my intention more clearly than more words :-)
Thanks for your attention,
Sascha Loetz
(sloetz@web.de)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 01:00:01 2025 UTC |
We shortly stumbled into that 'problem', too. Actually a contractor of ours did, that is. - We are sending everything through php, even static html. We do not have much, kiss (keep is stupid simple) and there some statistics reasons. - We host several loosely relatd sites, for clients who sometimes (let) code on their own; we add to theis sites, some other stuff is directly outsourced by us. - a young employee of one of our contractors recently approached me with a nicely made several-pages paper demonstrating a "bug in he server" ! Yes alas, he tried to use xml, clashed with php short tags, and here you go! He had no real knowledge of php at all, and he did not know we were using it, anyways. - I scanned our site for short tags: Found many. I tried to auto-replace them with long tags: many sites did not work any more. I tried to also replace "<?=" with "<?php echo" and it also did not work :-( - I ran a q&d count against our web sites & found roughly as many "<?" as ("<?[:whitespace:]" plus "<?=" plus "<?php") so => I propose to add an option to the php.ini that restricts short tags to ones like "<?" followed by whitespace or followed by "=" and leaves everything else alone. Pu <proprietor@pp4.de>