Bug #76608 [Ver]: Heredoc end label should not require an additional trailing character
| From: | requinix@php.net | Date: | Wed, 03 Apr 2019 19:18:21 +0000 |
| Subject: | Bug #76608 [Ver]: Heredoc end label should not require an additional trailing character | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220304@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76608&edit=1
ID: 76608
Updated by: requinix@php.net
Reported by: mattacosta at gmail dot com
Summary: Heredoc end label should not require an additional
trailing character
Status: Verified
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.2.7
Block user comment: N
Private report: N
New Comment:
Yeah. Easily.
echo <<<FOO
abcdefg
FOO, "hijk";
Previous Comments:
------------------------------------------------------------------------
[2019-04-03 19:09:09] chasepeeler at gmail dot com
Can you provide an example where you would ever not need a semicolon at the end of the heredoc,
then?
------------------------------------------------------------------------
[2019-04-03 18:07:55] requinix@php.net
> However, if you don't include a semicolon, you get an error:
The semicolon is not required *for the heredoc itself*. You still have to write valid code, and
$str = "
abcdefg"
echo $str;
is not valid code.
------------------------------------------------------------------------
[2019-04-03 17:47:55] chasepeeler at gmail dot com
Yes, in 7.3, the documentation states:
"The closing marker for doc strings is no longer required to be followed by a semicolon or
newline."
https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.core.heredoc
However, if you don't include a semicolon, you get an error:
<?php
$str = <<<FOO
abcdefg
FOO
echo $str;
> Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/eTKHe on line 7
If you add a semicolon after FOO, everything works. This is against 7.3.3:
https://3v4l.org/eTKHe
------------------------------------------------------------------------
[2018-07-11 17:57:49] mattacosta at gmail dot com
That error appears to be correct in previous versions though. Without the required line break, the
label would be part of the text instead, so it would make sense to expect T_END_HEREDOC.
------------------------------------------------------------------------
[2018-07-11 14:55:04] cmb@php.net
This does not appear particularly related to PHP 7.3, see
<https://3v4l.org/CeumU>.
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=76608
--
Edit this bug report at https://bugs.php.net/bug.php?id=76608&edit=1