php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36682 Heredoc not correctly parsed
Submitted: 2006-03-10 17:50 UTC Modified: 2006-03-13 12:01 UTC
From: daniele_dll at yahoo dot it Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.1.2 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2006-03-10 17:50 UTC] daniele_dll at yahoo dot it
Description:
------------
Terminating an heredoc without a newline cause a parse error.

The reported code was tested with php 5.0.4, 5.0.5 and 5.1.2

Reproduce code:
---------------
<?php
echo <<< HEREDOC_EOF

Test
Heredoc

All works fine!

HEREDOC_EOF;?>

Expected result:
----------------
This code should output the text into the heredoc

Actual result:
--------------
The execution of this code return a parse error

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-10 18:07 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The terminating new line is obligatory
 [2006-03-10 18:44 UTC] daniele_dll at yahoo dot it
This doesn't make sense!

Why an heredoc needs, to works correctly, a line only for it, without other stuff after the terminator (with a semicolon)?
If there is a terminator and an ending semicolon, the command terminates there, so i should add other commands in the same line without problems.

I don't think this is a "really" bug, but it is a "logical" bug.

If the heredoc terminator is founded and there is a semicolon to terminate the line, a new command can be executed, like all other structures in php.

i can write
<?php
$a = 1; $c = 'daniele_dll'; $b = 'test'; $a = $b; $b = $c; echo $a . $b . $c; echo print_r($_SERVER, true); die("ASD");
?>

without problems, so have heredoc that doesn't let to me to  add multiple commands after the heredoc termination (plus semicolon) doesn't make sense for me.

There is a particular reason to manage heredoc in this way?
 [2006-03-10 20:10 UTC] daniele_dll at yahoo dot it
for johannes@php.net:

in the description of the bug i've said that "Terminating an heredoc without a newline cause a parse error" ...

if you try an heredoc into an eval, terminating the stuff without a new line after the heredoc's terminator, you get a parse error for evalued code!

[code]
echo eval("return <<< EOF\r\nAll Works Correctly!\r\nEOF;"); 
[/code]

So there is this "real" problem (not related to other characters into the terminator line)

Or the heredoc's manual page need to be updated with a new sentence, like

[quote]
Remember that after the heredoc terminator is necessary a new line.
[/quote]

Or this, possible, bug need to be corrected
 [2006-03-11 17:02 UTC] derick@php.net
Reclassifying as a doc problem. The behavior is correct.
 [2006-03-13 12:01 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Closing delimiter (possibly followed by a semicolon) must be followed by a newline too."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jun 17 11:01:35 2025 UTC