Static initialization block support in Class?

From: Date: Tue, 17 Aug 2010 07:39:25 +0000
Subject: Static initialization block support in Class?
Groups: php.internals 
Request: Send a blank email to internals+get-49435@lists.php.net to get a copy of this message
Hello internals, I wonder whether it is possible to implement "static initialization block" feature in PHP, for example: <?php class Foo { } class Bar { public static $baz = 'baz'; public static $foo; static { // After loading this file, self::$foo is initialized as a Foo instance. self::$foo = new Foo(); } } ?> Currently we have to do this outside the class definition as static variable initialization is only limited to constant values. However in some circumstance, "dynamic" initialization of static variable is expected and meaningful. Thanks in advance! -- Best regards, Jingcheng Zhang P.R.China

« previous php.internals (#49435) next »