#34865 [Opn->Csd]: static unset documentation is unclear
| From: | vrana@php.net | Date: | Thu, 03 Nov 2005 11:00:09 +0000 |
| Subject: | #34865 [Opn->Csd]: static unset documentation is unclear | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969370767@lists.php.net to get a copy of this message | ||
ID: 34865
Updated by: vrana@php.net
Reported By: david at tulloh dot id dot au
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
"If a static variable is unset() inside of a function, unset() destroys
the variable only in the context of the rest of a function. Following
calls will restore the value of a variable." + fixed example.
Previous Comments:
------------------------------------------------------------------------
[2005-10-14 04:23:16] david at tulloh dot id dot au
Description:
------------
http://www.php.net/manual/en/function.unset.php#AEN183845
The documentation for unsetting static variables is very unclear and
confusing due to it's contradictory nature.
It is stated that the variable is destroyed, yet the example shows that
this clearly isn't the case. Rather the variable is only temporarily
destroyed, for the remainder of that function.
The example provided seems to demonstrate that unset has no effect,
removing the unset command produces exactly the same output.
I believe changing the descriptive text and changing the example to
something like the one below would make the behaviour far clearer.
Reproduce code:
---------------
<?php
function foo() {
static $bar;
$bar++;
echo "Before unset: $bar\n";
unset($bar);
$bar = 23;
echo "After unset: $bar\n";
}
foo();
foo();
foo();
?>
Before unset: 1
After unset: 23
Before unset: 2
After unset: 23
Before unset: 3
After unset: 23
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34865&edit=1