note 12057 added to x49958.php

From: Date: Wed, 21 Mar 2001 01:00:34 +0000
Subject: note 12057 added to x49958.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12592@lists.php.net to get a copy of this message
unset() also works differently with regard to variable scope. In php3, you can declare a variable as global inside a function, then unset() it. In php4, doing this does not affect the global. Use unset($GLOBALS['variable']) to unset a global from within a function. Note that this destroys the scope of the variable within the function at this point-- if you subsequently try to set $variable, it will be scoped locally even if you declared it global somewhere above the unset() call. You can of course declare it global again if you want to. http://www.php.net/manual/cs/x49958.php

« previous php.notes (#12592) next »