Re: is there anyway to use constants in a string?

From: Date: Mon, 19 Jul 2004 18:48:02 +0000
Subject: Re: is there anyway to use constants in a string?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-191056@lists.php.net to get a copy of this message
On Mon, 19 Jul 2004 10:22:42 -0700, barophobia <barophobia@gmail.com> wrote: > hello. > > <?php > > define("MY_CONSTANT", > "http://google.com/"); > > $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'; > here are my options: > > 1. assign the constant to a temporary variable and then use that. > > i.e. $tmp_MY_CONSTANT = MY_CONSTANT; > > 2. use an array instead of a constant > > i.e. $config['MY_CONSTANT'] = > "http://google.com/"; > > 3. find some secret way to work around the above two options and keep > my constants. > > anybody have any ideas to share? > > chris. > > p.s. if you don't know the "obvious reasons" just say so and i (or > someone else) will explain. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > !DSPAM:40fc053b159457466720899! > > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.general (#191056) next »