Actually I did try it and couldn't think of a way to work around the matter.
Thanks for the suggestion.

-----Original Message-----
From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 01, 2003 12:56 PM
To: Daniel R. Hansen
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Constants and "Here Document" Interpolation


At 16:56 01.03.2003, Daniel R. Hansen said:
--------------------[snip]--------------------
>Can anyone tell me if it is possible (and how) to use defined constants
>within "here document" content?  I've not been successful finding anything
>on this in the online docs.
--------------------[snip]--------------------

You simply could have tried it - it's trivial.

The answer: no, you cannot have a constant within a string, be it heredoc
or quoted. A constant must always reside on "native code level".

However you can easily concatenate strings and heredocs - both of the
examples below work correctly:

define('A_CONSTANT', 1);
$text1 = <<<EOT
This heredoc text contains the constant A_CONSTANT (
EOT
. A_CONSTANT . <<< EOT
) outside the heredoc construct...
EOT;

$text2 = "This quoted text contains the constant A_CONSTANT (" .
         A_CONSTANT .
         ") outside the string quotes...";
echo "$text1<br />$text2";

Output:
This heredoc text contains the constant A_CONSTANT (1) outside the heredoc
construct...
This quoted text contains the constant A_CONSTANT (1) outside the string
quotes...


--
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to