Quantcast
Channel: How to initialize static variables - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by Alister Bulman for How to initialize static variables

$
0
0

That's too complex to set in the definition. You can set the definition to null though, and then in the constructor, check it, and if it has not been changed - set it:

private static $dates = null;public function __construct(){    if (is_null(self::$dates)) {  // OR if (!is_array(self::$date))         self::$dates = array( /* .... */);    }}

Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>