#37047 [Opn->Bgs]: static executes after return
| From: | tony2001@php.net | Date: | Tue, 11 Apr 2006 22:21:31 +0000 |
| Subject: | #37047 [Opn->Bgs]: static executes after return | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95639@lists.php.net to get a copy of this message | ||
ID: 37047
Updated by: tony2001@php.net
Reported By: karoly at negyesi dot net
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Irrevelant
PHP Version: 5.1.2
New Comment:
Static variables are resolved in compile time.
Expected behaviour.
Previous Comments:
------------------------------------------------------------------------
[2006-04-11 22:15:50] karoly at negyesi dot net
Description:
------------
The code has been tested on PHP 4.3, 4.4, 5.0 and 5.1 various minors.
Reproduce code:
---------------
function storage($key) {
static $storage = array('a' => array('x', 'y'));
return $storage[$key];
static $storage = array('x', 'y'); // comment this out to see
expected result
}
var_dump(storage('a'));
Expected result:
----------------
array(2) {
[0]=>
string(1) "x"
[1]=>
string(1) "y"
}
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37047&edit=1