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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC