note 23187 added to language.variables.scope

From: Date: Thu, 11 Jul 2002 11:26:26 +0000
Subject: note 23187 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-32897@lists.php.net to get a copy of this message
It appears that in PHP4, the global statement creates a local reference to the global variable, rather than actually putting the global variable into the local scope. To illustrate, I have a function which needs to access a global array, and ensure it doesn't have previous values before setting its own. I was doing this: function myfunc() { global $somearray; unset($somearray); $somearray[] = $stuff; } In PHP3 (which didn't have variable references), this worked fine. However, in PHP4, all it's doing is unsetting the local *reference*, without affecting the global variable in any way. -- http://www.php.net/manual/en/language.variables.scope.php http://master.php.net/manage/user-notes.php?action=edit+23187 http://master.php.net/manage/user-notes.php?action=delete+23187 http://master.php.net/manage/user-notes.php?action=reject+23187

« previous php.notes (#32897) next »