php.net |  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
49 - 41 = ?
Subscribe to this entry?

 
 [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
THISISSTRING
);

if however you define a standard var like so:

$str_header=<<<THISISSTRING
the string goes here
THISISSTRING
;

then do:

define($html_header $str_header);

all works fine.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-07 07:26 UTC] nicos@php.net
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 http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Please read http://www.php.net/manual/en/function.define.php 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 http://www.php.net/manual/en/language.constants.php defines thus:

"Syntax
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, http://www.php.net/manual/en/language.types.string.php, where the Syntax for string is outlines as below.

"Syntax
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] sniper@php.net
There's nothing wrong/broken in it:

<?php

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

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC