php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81300 Heredocs closing identifiers
Submitted: 2021-07-26 14:34 UTC Modified: 2021-07-26 14:58 UTC
From: forums at artfulrobot dot uk Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.3.29 OS: Linux
Private report: No CVE-ID: None
 [2021-07-26 14:34 UTC] forums at artfulrobot dot uk
Description:
------------
---
From manual page: https://php.net/language.types.string
---

It appears that since 7.3 a heredoc may never include the heredoc identifier if it is the first item on an indented line.

Before 7.3, the interpretation was as described in the docs: indentation means the identifier would be considered part of the enclosed text. Which made sense.

Test script:
---------------
// In 7.2, this works, in 7.3+ it fails, misinterpreting the indented "SOMETHING" 
// on the 2nd line as closing the heredoc.
$string = <<<SOMETHING
   SOMETHING weird is going on.
SOMETHING;

Actual result:
--------------
**unexpected 'is' (T_STRING)** 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-26 14:58 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Type: Bug +Type: Documentation Problem -Package: Reproducible crash +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2021-07-26 14:58 UTC] cmb@php.net
See <https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes>.
Closing as duplicate of bug #78425.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 08 21:01:28 2024 UTC