Re: define() an array?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



lists@xxxxxxxxxxx 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux