Re: is there anyway to use constants in a string?
| From: | Justin Patrin | Date: | Mon, 19 Jul 2004 20:12:54 +0000 |
| Subject: | Re: is there anyway to use constants in a string? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-191070@lists.php.net to get a copy of this message | ||
Yes, I know. You can't use defined constants within a normal string,
so it won't work in a heredoc either:
define('FOO', 'bar');
echo "show me FOO";
You have to use:
echo 'show me '.FOO;
On Mon, 19 Jul 2004 12:05:40 -0700, barophobia <barophobia@gmail.com> wrote:
> On Mon, 19 Jul 2004 11:48:02 -0700, Justin Patrin <papercrane@gmail.com> wrote:
> > On Mon, 19 Jul 2004 10:22:42 -0700, barophobia <barophobia@gmail.com> wrote:
>
> > > $my_string = <<<QQQ
> > >
> > > MY_CONSTANT: does not work for obvious reasons
> > > {MY_CONSTANT}: does not work for obvious reasons
> > > {$MY_CONSTANT}: does not work for obvious reasons
> > >
> > > QQQ;
>
> > $my_string = 'pre'.MY_CONSTANT.'post';
>
> yeah but did you notice in my example i'm using a heredoc? i did that
> on purpose. :)
>
> chris.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> !DSPAM:40fc1eea223154764716344!
>
>
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--