Re: Re[PHP] Dynamic constant names -SOLVED

From: Date: Tue, 27 Mar 2001 19:49:14 +0000
Subject: Re: Re[PHP] Dynamic constant names -SOLVED
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45768@lists.php.net to get a copy of this message
I'm sorry to jump in mid-stream here (I've been offline for a while), but was $constant_value=${constant_name}; suggested? eval's spook me, so I would prefer this solution over the working suggestion you received. This works for me on 4.0.4: $test_name="ta_dah"; define("constant_name","test_name"); $constant_value=${constant_name}; echo $constant_value; -- March 27, 2001: Tuesday is a scissors. Opposed blades make a finer cut. --http://artwells.com/oracula/ On Tue, 27 Mar 2001, Geoff Caplan wrote: > Hi folks > > I had 2 suggestions from the list: > > 1) indirection - $constant_value = $$constant_name ; > > I had already tried this, but couldn't get it to work. Unless I am > missing something it just gives an "Undefined Variable" error. > > 2) eval("\$constant_value = $constant_name;") ; > > This does work. Thanks Paul! > > Geoff Caplan > > >

« previous php.general (#45768) next »