php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45204 Comma should be a valid HEREDOC keyword suffix
Submitted: 2008-06-08 01:28 UTC Modified: 2018-04-13 20:03 UTC
Votes:17
Avg. Score:3.9 ± 1.0
Reproduced:17 of 17 (100.0%)
Same Version:1 (5.9%)
Same OS:12 (70.6%)
From: signe at cothlamadh dot net Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.6 OS: All
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: signe at cothlamadh dot net
New email:
PHP Version: OS:

 

 [2008-06-08 01:28 UTC] signe at cothlamadh dot net
Description:
------------
Comma should be added to the allowable line suffixes for HEREDOC keywords.  The use of HEREDOC in an array becomes very ungainly because the keyword can not be terminated followed by a comma.

Currently the addition of a comma renders the scripting engine unable to recognize the keyword as being the terminator for the HEREDOC string and the rest of the script is absorbed resulting in an "syntax error, unexpected $end" E_PARSE_ERROR.



Reproduce code:
---------------
<?php
$foo = array(
    'blah' => <<<SQL
        SELECT
            *
        FROM
            test
        WHERE
            RAND()
SQL,
    'foo' => 'bar',
    'baz' => 'blat'
);  
print_r($foo);
?>

Expected result:
----------------
The comma should not prevent the HEREDOC string from being terminated, and should be a valid suffix, just like semi-colon is.

Actual result:
--------------
Parse error: syntax error, unexpected $end in test.php on line 16

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-31 00:21 UTC] cmb@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2018-03-15 18:17 UTC] lunakid at gmail dot com
Greetings from 2018, happy decennial! ;)
 [2018-04-13 20:03 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2018-04-13 20:03 UTC] nikic@php.net
This will be possible as part of https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes, which just landed in master (PHP 7.3).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC