note 10843 added to define
| From: | andrew at andrew dot org | Date: | Tue, 23 Jan 2001 17:06:32 +0000 |
| Subject: | note 10843 added to define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10183@lists.php.net to get a copy of this message | ||
how can I get the value of a constant whose name is stored into a string variable?
the only way I found is not very elegant, that is
// $constant_name = "CONSTANT";
eval("\$myvar = " . $constant_name . ";");
I think PHP lacks some ad hoc function here, something like ini_get() for php.ini values. Or at
least I have not found any function doing this.
andrew
http://www.php.net/manual/en/function.define.php