|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 >
Patchesfix-77812 (last revision 2019-08-17 15:54 UTC by cmb@php.net)Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
The problem in php interactive mode is still there. Here I show How I create a php file and add a simple function that echoes a string from a heredoc. But the same function in interactive mode is not even recognized as a complete heredoc, so I cannot even close the function. see this: santiagoarizti@santis-mac:~$ docker run --rm -it php:7.3 bash root@a8df21f382dd:/# echo -e '#!/usr/local/bin/php\n<?php\nfunction sayHello($name) {\n echo <<<EOF\n hola $name\n EOF;\n}\nsayHello($argv[1]);echo PHP_EOL;\n' > santi.php root@a8df21f382dd:/# cat santi.php #!/usr/local/bin/php <?php function sayHello($name) { echo <<<EOF hola $name EOF; } sayHello($argv[1]);echo PHP_EOL; root@a8df21f382dd:/# php santi.php Santiago hola Santiago root@a8df21f382dd:/# php -a Interactive shell php > function sayHello($name) { php { echo <<<EOF <<< > hola $name <<< > EOF; <<< > } Notice how I am still inside heredoc according to php. Here is a simpler example without anything but an echo: santiagoarizti@santis-mac:~$ docker run --rm -it php:7.3 Interactive shell php > echo <<<EOF <<< > this works fine, <<< > old syntax <<< > EOF; this works fine, old syntax php > echo <<<EOF <<< > this doesn't <<< > work, new syntax <<< > EOF; <<< >