PHP 4.0 Bug #6881 Updated: static variables can't be intialized by function, variable, etc.

From: Date: Wed, 08 Nov 2000 23:30:33 +0000
Subject: PHP 4.0 Bug #6881 Updated: static variables can't be intialized by function, variable, etc.
Groups: php.dev 
Request: Send a blank email to php-dev+get-37469@lists.php.net to get a copy of this message
ID: 6881 Updated by: hholzgra Reported By: simon@comsys.ntu-kpi.kiev.ua Status: Closed Bug Type: *General Issues Assigned To: Comments: you may only use constant values to initialize static variables in PHP 4, no variables or expressions this is very similar to initialising class members and happens for the same reason: as PHP 4 parses and pre-compiles the whole file before execution of the PHP code even starts the engine has no chance to know the value of a variable or expression like $a in your example see also the 'incompatibilities' section unter php.net/version4 Previous Comments: --------------------------------------------------------------------------- [2000-09-25 22:16:07] simon@comsys.ntu-kpi.kiev.ua #!php -q <? $a = "abc"; function foo() { global $a; static $b = $a; static $arr = array($a); } ?> I can't init static variable by another variable or function. Even more PHP give error while parsing this code. --------------------------------------------------------------------------- [2000-09-25 22:06:38] simon@comsys.ntu-kpi.kiev.ua #!php -q <? $a = "abc"; function foo() { global $a; static $b = $a; static $arr = array($a); } ?> I can't ini static variable by another variable or function. Even more PHP give error while parsing this code. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6881

« previous php.dev (#37469) next »