note 21711 deleted from function.unset by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 03:19:48 +0000 |
| Subject: | note 21711 deleted from function.unset by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58495@lists.php.net to get a copy of this message | ||
Note Submitter: admin\@/networkessence.net
----
If a static variable is unset() inside of a function, unset() destroyes the variable and all its
references.
This statement is clearly false given the following example:
function foo() {
static $a;
$a++;
echo "$a\n";
unset($a);
}
foo();
foo();
foo();
The above example would output:
1
2
3
If $a was being destroyed, then it would not increment (bug I guess). BUT
unset does work properly outside of functions
Example:
static $a;
$a++;
echo $a;
unset($a);
$a++;
echo $a;
unset($a);
would output:
1
1
which is correct. I would assume this is a bug considering the output of the first example
contradicts the manual.