php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50786 HEREDOC at EOF Error
Submitted: 2010-01-17 18:25 UTC Modified: 2010-01-18 10:11 UTC
From: ldrut at charter dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.12 OS: LINUX
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ldrut at charter dot net
New email:
PHP Version: OS:

 

 [2010-01-17 18:25 UTC] ldrut at charter dot net
Description:
------------
Bug observed in 5.2.9. Shared hosting - can't upgrade. Review of changelog does not suggest a fix has been made.

Documentation stated HEREDOC closing line must be only text on line, but it also appears that the closing text MUST be followed by a new line. If the HEREDOC closes the file with no terminating /n, an error is produced. Addition of a 1-line comment in a following line clears the error (as does anything else that forces a newline - my editor strips trailing /n from the document).

I'm not sure if this is a documentation error or a scripting error as I don't know which way is intended behavior.

Reproduce code:
---------------
<?php
$v = <<<EOF
Anything, but there is nothing in the file following
the upcoming semicolon
EOF;

Expected result:
----------------
no output. Assigns variable.

Actual result:
--------------
"Parse error: syntax error, unexpected $end"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-18 10:11 UTC] jani@php.net
In our manual it says quite clearly:

"The closing delimiter (possibly followed by a semicolon) must also be followed by a newline." http://php.net/heredoc

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 10:00:02 2025 UTC