Hi, as we introduce NOWDOC in 5.3 it would be logical to allow a double quoted syntax sister of NOWDOC which acts as HEREDOC (same as for $var = "$var" vs $var = '$var'). Currently we have the following options:
$var = "Hello world"; $str = <<<LABEL $var LABEL; $str = <<<'LABEL' $var LABEL; The first one is HEREDOC and $var would be evaluated. The second one is NOWDOC and $var would be used literally. The following patch adds a third version: $str = <<<"LABEL" $var LABEL; This acts as HEREDOC, therefore $var would be interpreted. Comments? cu, Lars
Index: Zend/zend_language_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.131.2.11.2.13.2.9
diff -u -r1.131.2.11.2.13.2.9 zend_language_scanner.l
--- Zend/zend_language_scanner.l 22 Mar 2008 17:59:52 -0000 1.131.2.11.2.13.2.9
+++ Zend/zend_language_scanner.l 22 Mar 2008 20:12:19 -0000
@@ -1643,13 +1643,15 @@
}
-<ST_IN_SCRIPTING>b?"<<<"{TABS_AND_SPACES}{LABEL}{NEWLINE} {
+<ST_IN_SCRIPTING>b?"<<<"{TABS_AND_SPACES}["]?{LABEL}["]?{NEWLINE} {
char *s;
int bprefix = (yytext[0] != '<') ? 1 : 0;
+ int quotes = (yytext[3] == '"') ? 2 : 0;
+ int lquote = (quotes == 2) ? 1 : 0;
CG(zend_lineno)++;
- CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0);
- s = yytext+bprefix+3;
+ CG(heredoc_len) = yyleng-bprefix-quotes-3-1-(yytext[yyleng-2]=='\r'?1:0);
+ s = yytext+bprefix+3+lquote;
while ((*s == ' ') || (*s == '\t')) {
s++;
CG(heredoc_len)--;
heredoc_012.phpt
Description: application/php
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
