php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77812 7.3 heredoc syntax not documented in manual proper
Submitted: 2019-03-27 20:13 UTC Modified: 2019-03-28 09:54 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:2 of 3 (66.7%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: bugs dot php dot net at ss dot st dot tc Assigned:
Status: Re-Opened Package: Strings related
PHP Version: 7.3 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-03-27 20:13 UTC] bugs dot php dot net at ss dot st dot tc
Description:
------------
Old, pre-7.3 heredoc syntax works as expected in PHP 7.3 interactive shell:

$ php7.3 -a
Interactive shell

php > echo <<<FOO
<<< > bar
<<< > FOO;
bar


Now let's try 7.3 heredoc syntax:

$ php7.3 -a
Interactive shell

php > echo <<<FOO
<<< >     bar
<<< >     FOO;
<<< >


$ php7.3 -a
Interactive shell

php > print(<<<FOO
<<< > xx
<<< > FOO);
<<< >


$ php7.3 -a
Interactive shell

php > echo <<<FOO
<<< >     xxx
<<< >     FOO;
<<< > FOO
php > ;
xxxPHP Warning:  Use of undefined constant FOO - assumed 'FOO' (this will throw an Error in a future version of PHP) in php shell code on line 4


The latter example works well in PHP 7.2:

$ php7.2 -a
Interactive shell

php > echo <<<FOO
<<< >     xxx
<<< >     FOO;
<<< > FOO
php > ;
    xxx
    FOO;
php >


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-28 00:03 UTC] a at b dot c dot de
This is the first entry listed under the "Backward Incompatible Changes" section of the 7.3 migration guide.

http://www.php.net/manual/en/migration73.incompatible.php
 [2019-03-28 00:11 UTC] bugs dot php dot net at ss dot st dot tc
-Status: Open +Status: Closed
 [2019-03-28 00:11 UTC] bugs dot php dot net at ss dot st dot tc
Oh thank you so much. I didn't look there.
Instead, was staring at https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc which doesn't even mention new syntax.
Thanks again.
 [2019-03-28 09:54 UTC] cmb@php.net
-Summary: 7.3 Interactive shell won't digest 7.3 heredoc syntax +Summary: 7.3 heredoc syntax not documented in manual proper -Status: Closed +Status: Re-Opened -Type: Bug +Type: Documentation Problem -Operating System: Linux (didn't try Win) +Operating System: * -PHP Version: 7.3.3 +PHP Version: 7.3
 [2019-03-28 09:54 UTC] cmb@php.net
> […] which doesn't even mention new syntax.

Re-opening as doc bug, then.
 [2019-04-03 17:54 UTC] chasepeeler at gmail dot com
The documentation at https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.heredoc-nowdoc is definitely wrong.

As written:
<?php
$str = <<<FOO
abcdefg
   FOO
FOO;
?>

will not produce the error mentioned. Instead, it will give the following:
Parse error: Invalid body indentation level (expecting an indentation level of at least 4)

If you don't indent that line:
<?php
$str = <<<FOO
abcdefg
FOO
FOO;
?>

You'll get an error, but still not the one reported. This appears to be a bug though, as it's requiring a semicolon after the identifier, despite the fact that documentation says that is no longer required. See https://bugs.php.net/bug.php?id=76608
 [2019-04-03 21:07 UTC] chasepeeler at gmail dot com
So, it doesn't appear the other issue I mentioned in my previous email is actually a bug. The fact that the migration documentation is incorrect still applies, though.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 20:01:26 2019 UTC