Another tiny syntax patch

From: Date: Sun, 26 Jul 2009 09:12:54 +0000
Subject: Another tiny syntax patch
Groups: php.internals 
Request: Send a blank email to internals+get-45094@lists.php.net to get a copy of this message
For the sake of the heck of it, I'm gonna offer up this tiny patch I'm using in one of my projects. I don't really care if it gets included in anything or not, just thought it might interest someone. Effect: Adds a "<?php=" syntax which behaves identically to "<?=", but works without the use of short_tags. Caveat: The formation "<?php=" is not valid XML. Specifically, section 2.6 of [1] defines a PITarget as a Name, which in turn is made up of NameChars (section 2.3), which do not include the "=" character. Advantage: Saves five characters of typing. "<?php= $myvar ?>" versus "<?php echo $myvar; ?>". Just thought I'd throw it out there. Index: Zend/zend_language_scanner.l =================================================================== --- Zend/zend_language_scanner.l (revision 286353) +++ Zend/zend_language_scanner.l (working copy) @@ -1537,6 +1588,15 @@ } +<INITIAL>"<?php=" { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG_WITH_ECHO; +} + + <INITIAL>"<?php"([ \t]|{NEWLINE}) { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; [1] Extensible Markup Language (XML) 1.0 Fifth Edition, http://www.w3.org/TR/2008/REC-xml-20081126/ -- Gwynne

« previous php.internals (#45094) next »