Re: PHP 4.0 Bug #5289 Updated: Use of reset on a global array creates local array in function

From: Date: Thu, 29 Jun 2000 20:05:54 +0000
Subject: Re: PHP 4.0 Bug #5289 Updated: Use of reset on a global array creates local array in function
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-22967@lists.php.net to get a copy of this message
That may be the new definition, but it wasn't the case under php3. I didn't spot anything in your differences notes for this. Is there a better way to do it? My code fragment just highlights the problem, it's actually gleaned from debugging a much larger and complex script. What I want to do is replace an array with fresh contents when a loading function is invoked. This is most simply done by using unset. This array is then used in many other associated functions and each expects only the latest version of the array, as loaded by the last invokation of the loading function. To change all references to $GLOBALS wouldn't fulfil my need here. Wouldn't unset($GLOBALS["name"]) just do the same thing? To my mind the fact that a given variable is defined global should be retained after using unset, it should merely initialise the array to empty but keep it global for further references in the function. My workaround to add a further global statement after using unset() to redeclare it as global works in php4, but this doesn't work under php3 - making this workaround unportable. Regards Alan Bug Database wrote: > > ID: 5289 > Updated by: stas > Reported By: alan.frostick@iconmedialab.com > Status: Closed > Bug Type: Scripting Engine problem > Assigned To: > Comments: > > That's true. That's what unset does on globals. If you like it other way, > use $GLOBALS["name"]. > > Full Bug description available at: > http://bugs.php.net/version4/?id=5289 -- Alan Frostick Icon Medialab AG Hamburg Gasstr.4 D- 22761 Hamburg Germany home: http://www.iconmedialab.de mailto:alan.frostick@iconmedialab.com phone: +49- (0)40- 8979- 8219 fax: +49- (0)40- 8979- 8989

« previous php.dev (#22967) next »