[PHP] Dynamic constant names -SOLVED

2001-03-27 Thread Geoff Caplan
Art, Thanks for the suggestion, but I think there is a flaw in your solution. The original issue was how to get at the value of a constant where the $constant_name is dynamically created as a variable. In your solution you have defined constant_name as a constant! So when you assign it, it does

[PHP] Dynamic constant names - SOLVED

2001-03-27 Thread Geoff Caplan
Hi folks I mailed this to the list some time ago, but it seems to have got "lost" so here is is again... 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

[PHP] Re: Re[PHP] Dynamic constant names -SOLVED

2001-03-27 Thread Art Wells
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_nam

Re: [PHP] Dynamic constant names

2001-03-27 Thread CC Zona
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Geoff Caplan) wrote: > I am trying to create a constant name dynamically and then get at the > value. > > // We set up the constant > define( CONSTANT_1 , "Some value" ) ; > > // Later we try to use it dynamically ... > $constant_number = 1 ;

[PHP] Re[PHP] Dynamic constant names -SOLVED

2001-03-27 Thread Geoff Caplan
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. Th

RE: [PHP] Dynamic constant names

2001-03-27 Thread Neil Kimber
You need another level of indirection. Try: $constant_value = $$constant_name ; -Original Message- From: Geoff Caplan [mailto:[EMAIL PROTECTED]] Sent: 27 March 2001 14:19 To: PHP General List Subject: [PHP] Dynamic constant names Hi folks I am trying to create a constant name

[PHP] Dynamic constant names

2001-03-27 Thread Geoff Caplan
Hi folks I am trying to create a constant name dynamically and then get at the value. // We set up the constant define( CONSTANT_1 , "Some value" ) ; // Later we try to use it dynamically ... $constant_number = 1 ; $constant_name = ( "CONSTANT_" . $constant_number ) ; // We try to assign the c