Dynamic constant call
Posted on 2006-04-09
Ok, here's the deal
I have a constant defined, hypothetically as such --> define("CONSTANT1", "This value");
In my script, I would like to be able to populate a variable with the name of that constant, i.e. $myvar = "CONSTANT1";
Now, I would like to be able to refer to the defined value of that constant by calling it up using it's name as stored in $myvar
In otherwords, a form of variable substitution, of sorts.
For instance --> echo "The value of the called constant = " . $myvar; <-- only $myvar is to now somehow directly reference CONSTANT1 as though I had actually called it directly as such --> echo "The value of the called constant = " . CONSTANT1;
Any ideas how I would go about acheiving this or is this not even possible?