note 30288 deleted from language.variables.scope by danbrown

From: Date: Mon, 18 May 2009 01:41:28 +0000
Subject: note 30288 deleted from language.variables.scope by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155577@lists.php.net to get a copy of this message
Note Submitter: ben-xo aatt dubplates.org ---- regarding the above "unset" example: I quote from the manual page for "unset". "If a static variable is unset() inside of a function, unset() destroyes the variable and all its references. " As mentioned above, on this page, static vars are implemented as references. When you unset() a reference, what you are doing is deleting a particular name for that variable. In your example, you delete the LOCAL NAME $a, but the static contents are still there (hidden) and next time you call your function, a NEW LOCAL NAME (again $a...) is linked to the SAME backing data. Workaround would be something like "$a = null". unset($a) is very much like $a = &null however, which, if you read the notes above, won't have the desired affect on static or global variables.

« previous php.notes (#155577) next »