php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69231 Example 3 seems wrong
Submitted: 2015-03-12 15:10 UTC Modified: 2015-03-12 16:07 UTC
From: alejandroivan at ingenieros dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alejandroivan at ingenieros dot com
New email:
PHP Version: OS:

 

 [2015-03-12 15:10 UTC] alejandroivan at ingenieros dot com
Description:
------------
---
From manual page: http://www.php.net/language.types.string
---

Is example 3 correct? The original example says:

<?php
var_dump(array(<<<EOD
foobar!
EOD
));
?>

According to heredoc explanation, the string should end with "EOD;":

<?php
var_dump(array(<<<EOD
foobar!
EOD;
));
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-12 16:07 UTC] salathe@php.net
-Status: Open +Status: Not a bug
 [2015-03-12 16:07 UTC] salathe@php.net
Yes, the example is correct.

The semicolon is a statement terminator, but in the cited example the statement is not finished yet as we're in the middle of providing arguments in a function call.

When used in this way, the closing heredoc identifier must be on a line entirely of its own. E.g. the following is not allowed:

<?php
vr_dump(array(<<<EOD
foobar!
EOD));
?>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 17:01:33 2025 UTC