php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35525 static + heredoc = parse error
Submitted: 2005-12-02 18:50 UTC Modified: 2005-12-02 20:43 UTC
From: snoyes at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.1 OS: Windows XP
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: snoyes at gmail dot com
New email:
PHP Version: OS:

 

 [2005-12-02 18:50 UTC] snoyes at gmail dot com
Description:
------------
Cannot assign static variables using heredoc.  The manual indicates heredoc is a string delimiter, interchangable with double quotes.  When assigning to static variables, it acts like an expression.

Reproduce code:
---------------
<?php
static $x <<<TEXT
any text here
TEXT;

echo $x;
?>

Expected result:
----------------
any text here

Actual result:
--------------
Parse error: parse error, unexpected T_START_HEREDOC, expecting ',' or ';' in [file] on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-02 18:54 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

. 
 [2005-12-02 20:43 UTC] snoyes at gmail dot com
Hmm, just noticed that there is an error in my reproduce code (missing the '='), but corrected, it still causes the indicated error.

Code should be:
static $x = <<<TEXT
any text here
TEXT;

If we remove the "static" keyword, there is no error.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 06 23:00:01 2025 UTC