ID: 34865 Updated by: [EMAIL PROTECTED] 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