views:

49

answers:

2

is it possible to display constants php's EOT? for example:


<?
  define('Hey', "HellO");
  echo
<<<EOT
Hey
EOT;
?>

+3  A: 

Nope. Just like you can't display a constant inside of a string. There are only two real ways to access a constant's value:

Directly in code:

$foo = Hey;

Or using the constant function:

$foo = constant('Hey');
ircmaxell
The hrids way would be to do a concatenation liek 'Echo static: ' . Hey . ' is fun';
ITroubs
@iTroubs: Assuming you mean "third way", no it isn't, that is "Directly in code", so it is the first way again.
David Dorward
@iTroubs: to PHP's parser, it's identical to putting it directly in code (the same parser tokens are generated)...
ircmaxell
You are right. I see my error ;-)
ITroubs
+2  A: 

No, the heredoc syntax (<<<) acts just like a double quoted string in PHP. It will expand variables, but not constants.

You can see a comment in the PHP documentation indicating this here. There is also an editors note on the comment saying that it is correct.

Alan Geleynse