Re: Handling of constants in strings
| From: | Richard Lynch | Date: | Mon, 01 Jul 2002 22:02:55 +0000 |
| Subject: | Re: Handling of constants in strings | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-104806@lists.php.net to get a copy of this message | ||
>Hi,
>when reading about constants (define('MY_CONSTANT', 'my value'))
>I got convinced that they are pretty usefull.
>
>But now it seems to me, that I can't use them inside a string:
>$my_string = "This is MY_CONSTANT and I love it!";
>
>but that I must take them out:
>$my_string = "This is" . MY_CONSTANT . "and I love it!";
>
>Isn't there a way around?
>And must I suspect more strange things to come with constants?
Try this:
$my_string = "This is {MY_CONSTANT} and I love it!";
Can't promise it will work, mind you...
It's not all that common to bury constants in strings... And is the extra "
. " K ". " that big a deal? Seems a small price for cleaner code.
--
Like Music? http://l-i-e.com/artists.htm