Re: define() an array?
| From: | Stut | Date: | Fri, 20 Apr 2007 09:02:51 +0000 |
| Subject: | Re: define() an array? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253327@lists.php.net to get a copy of this message | ||
lists@dwsasia.com wrote:
I thought I could define() and array. However, when I do this: define("THECONSTANT", array(1,2,3)); print_r(THECONSTANT); it prints THECONSTANT and not the array :( according to the manual: bool define ( string $name, mixed $value [, bool $case_insensitive] ) And isn't "mixed" of any type?No. The value of a constant must be a scalar, i.e. a string or a number. So it is "mixed", but does not allow all types. If you really want to you can serialise your array into the constant, but that will incur a cost whenever you need to use it. -Stut