Re: Why Constants could Not be Array?

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

 



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@xxxxxxxxx>
> To: php-general@xxxxxxxxxxxxx
> Date created: , 12:51:15 PM
> Subject:  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
> 


-- 
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