Bug #13610 Updated: heredoc: any chars (even white space) after closing ";" causes error
| From: | destes at ix dot netcom dot com | Date: | Wed, 08 May 2002 18:26:57 +0000 |
| Subject: | Bug #13610 Updated: heredoc: any chars (even white space) after closing ";" causes error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-7257@lists.php.net to get a copy of this message | ||
ID: 13610
Updated by: destes@ix.netcom.com
Reported By: rprangnell@hotmail.com
Status: Open
Bug Type: Feature/Change Request
Operating System: Windows98
PHP Version: 4.0.6
New Comment:
This would be very useful to change. Additionally if/when this is
closed, Bug #5804 is a duplicate of this. Thanks,
Steve
Previous Comments:
------------------------------------------------------------------------
[2002-01-28 22:00:08] torben@php.net
Yeesh. Scratch that. :) The issue remains but the patch I
just posted here indicates a seious need for supper.
Torben
------------------------------------------------------------------------
[2002-01-28 21:56:41] torben@php.net
Here's a quick patch which just allows text *after* the
semicolon, and doesn't appear to affect anything else, so
BC shouldn't be a problem. stat@php.net told me before that
this is 'intentional', but no-one has yet explained why...
Note that this patch may not be the best solution, but it
does illustrate what I'm after.
Torben
Index: zend_language_scanner.l
===================================================================
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.43
diff -u -r1.43 zend_language_scanner.l
--- zend_language_scanner.l 2002/01/06 15:21:09 1.43
+++ zend_language_scanner.l 2002/01/29 02:54:16
@@ -1256,7 +1256,7 @@
}
-<ST_HEREDOC>^{LABEL}(";")?{NEWLINE} {
+<ST_HEREDOC>^{LABEL}(";")? {
int label_len;
unsigned char unput_semicolon;
------------------------------------------------------------------------
[2001-10-09 17:59:30] jeroen@php.net
Patch available here:
http://www.A-Eskwadraat.nl/~jeroen/php/looser_heredoc.diff
which changes behaviour to:
A heredoc is considered closed when the heredoc identifier appears
directly after a newline. Remaining characters are allowed, provided
they are invalid identifyer characters.
Example:
<?php
mail('jeroen@php.net', 'heredoc test', <<<TEXT
Hello Jeroen,
Greets!
TEXT, 'Cc: bla@example.com');
?>
And this works:
<?php
echo <<<HEREDOC
bla
HEREDOCUMENTATION;
HEREDOC; // here the heredoc ends
?>
But this doesn't:
<?php
echo <<<HEREDOC
bla
HEREDOC UMENTATION;
HEREDOC;
?>
for the same reason as this is:
echo "bla" UMENTATION;
causes a parse error.
------------------------------------------------------------------------
[2001-10-09 16:27:02] jeroen@php.net
This behaviour is documented in the strings section, subsection
heredoc.
I agree that this is quite annoying and strange. It can be easily
modified, for example to allow anything afterwards. But this could
break BC (though not likely):
$bla = <<<HEREDOC
Text
text
HEREDOC is great!
text
HEREDOC;
Other solutions would be quite arbirary (as is the current solution by
the way). Most consistent would be allowing a heredoc-string at all
places where a quoted string is also allowed.
------------------------------------------------------------------------
[2001-10-09 06:10:40] derick@php.net
It is expected behavior. Although I agree it is not very handy that
this is not possible. Making this a feature request.
Derick
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/13610
--
Edit this bug report at http://bugs.php.net/?id=13610&edit=1