note 23187 deleted from language.variables.scope by dams

From: Date: Sun, 28 Jul 2002 14:49:40 +0000
Subject: note 23187 deleted from language.variables.scope by dams
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-33822@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.

« previous php.notes (#33822) next »