php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64943 Heredoc syntax specification
Submitted: 2013-05-29 15:08 UTC Modified: 2013-10-04 17:31 UTC
From: jduartedj at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
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: jduartedj at gmail dot com
New email:
PHP Version: OS:

 

 [2013-05-29 15:08 UTC] jduartedj at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.types.string
---

It is not mentioned that heredoc syntax requires:

* NO SPACE after each identifier
* NO CHARACTERS before the END identifier

Test script:
---------------
//PROPER
    echo <<<EOS
        my freestyle text
EOS;

//IMPROPER (space after "<<<EOS")
    echo <<<EOS 
        my freestyle text
EOS;

//IMPROPER  (space after "EOS;")
    echo <<<EOS
        my freestyle text
EOS; 

//IMPROPER  (spaces before "EOS;")
    echo <<<EOS
        my freestyle text
    EOS;

Expected result:
----------------
Fail all except first


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-29 17:20 UTC] sixd@php.net
Both issues are already covered in the doc.

I agree the first one could be made more obvious: currently that page says "After this operator, an identifier is provided, then a newline."  This could be 
improved.

The warning box is already very clear about your second point:
"It is very important to note that the line with the closing identifier must 
contain no other characters, except possibly a semicolon (;)."  This could also 
be improved because the semicolon is mandatory.
 [2013-10-04 17:30 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331668
Log: #64943 clarity in description
 [2013-10-04 17:31 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-10-04 17:31 UTC] krakjoe@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.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 02:00:01 2026 UTC