Using expressions to assign PHP static variables
Posted by Kelvin on 14 Jan 2010 at 01:11 pm | Tagged as: programming, PHP
OK. The PHP manual explicitly states you CANNOT use an expression when assigning to a static variable.
You can, however, do this:
class MyClass { public static $a = 1; public static $b; public static function init() { self::$b = self::$a + 1; } } MyClass::init();
Nifty eh?