Re: Why Constants could Not be Array?
| From: | Stuart Dallas | Date: | Sat, 30 Apr 2011 16:55:21 +0000 |
| Subject: | Re: Why Constants could Not be Array? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312598@lists.php.net to get a copy of this message | ||
On Saturday, 30 April 2011 at 17:52, Andre Polykanine wrote:
Hello Walkinraven,
>
> I use serialize for that.
> define("MY_CONSTANT", serialize(array("1", "2",
> "hello")));
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile
> My blog: http://oire.org/menelion (mostly in Russian)
> Twitter: http://twitter.com/m_elensule
> Facebook: http://facebook.com/menelion
That's not a class constant. That type of constant is not defined until that line is executed
(so an array is a valid value), whereas class constants are declared when the file is parsed.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
> ------------ Original message ------------
> From: Walkinraven <walkinraven@gmail.com>
> To: php-general@lists.php.net
> Date created: , 12:51:15 PM
> Subject: [PHP] Why Constants could Not be Array?
>
>
> For needing a constants=array, I have to use
> 'public static $a = array(...)'
>
> instead.
>
> Why the language could not relax the restriction of constants?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>