Bug #13967 Updated: unset() on a static variable causes it to forget it is static
| From: | jan@php.net | Date: | Wed, 12 Dec 2001 23:01:03 +0000 |
| Subject: | Bug #13967 Updated: unset() on a static variable causes it to forget it is static | ||
| References: | 1 | Groups: | php.dev php.doc |
| Request: | Send a blank email to php-dev+get-73411@lists.php.net to get a copy of this message | ||
ID: 13967
Updated by: jan
Reported By: david@php.net
Old Status: Open
Status: Closed
Bug Type: Documentation problem
Operating System: Debian Linux
PHP Version: 4.0.6
New Comment:
fixed in CVS
Previous Comments:
------------------------------------------------------------------------
[2001-11-07 18:29:43] jeroen@php.net
Like with global, static is a keyword linking a variable specially. unset() will completely destroy
the variable with all links it might have. This is expected behaviour, or at least a known
side-effect. With the current way of handling variables internally, this is not going to change.
This isn't stressen enough in the manual, so changing to documentation problem.
------------------------------------------------------------------------
[2001-11-06 21:49:10] david@php.net
Doing unset() on a static variable causes it to forget the fact that it is static for the rest of
the function.
e.g.
<?
function abc() {
static $a = 123;
echo "On entry, a = $a\n";
unset($a);
$a = 456;
}
abc();
abc();
?>
should give 123 then 456. It gives 123 and 123.
Replacing unset($a) with $a = null, or removing the unset() entirely has the desired result of
giving 123 then 456.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=13967&edit=1