|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21956 define constants not taking heredoc strings as value
Submitted: 2003-01-29 19:52 UTC Modified: 2003-02-07 23:34 UTC
From: moptop69 at ntlworld dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.0 OS: Win2k
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.
Block user comment
Status: Assign to:
Bug Type:
From: moptop69 at ntlworld dot com
New email:
PHP Version: OS:


 [2003-01-29 19:52 UTC] moptop69 at ntlworld dot com
when using define() to create constants, it all seems to work fine when using standard strings.

However, under the definition for the arguments on define(), it says that the define function can take string() as an argument.

looking at strings, heredoc is a valid string argument, however when trying to define a constant as follows, the constant returns a null string.

define($html_header, <<<THISISSTRING
the string goes here

if however you define a standard var like so:

the string goes here

then do:

define($html_header $str_header);

all works fine.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-07 07:26 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Please read it has good nice examples on it.
 [2003-02-07 09:38 UTC] moptop69 at ntlworld dot com
if this is not a bug, then it would therefore be the same across all platforms?  which would then I surmise be a documentation problem.

Since defines thus:

You can define a constant by using the define()-function. Once a constant is defined, it can never be changed or undefined. 

Only scalar data (boolean, integer, float and string) can be contained in constants."

which then links to the string defintion page here,, where the Syntax for string is outlines as below.

A string literal can be specified in three different ways. 

single quoted 
double quoted 
heredoc syntax 

so according to the documentation, define can take heredoc syntax as a valid string, since heredoc is defined as a valid string syntax.

if this is incorrect, then please change this to a documentation issue by all means, but this is not a bugus bug, it happens.
 [2003-02-07 23:34 UTC]
There's nothing wrong/broken in it:


define('foo', <<<THISISSTRING
the string goes here

echo foo;


outputs 'the string goes here' so it works fine.

You're just doing something wrong, most likely you
have some empty space before the heredoc end tag..
Not bug.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 20:03:39 2023 UTC