Re: Global variable unset in function

From: Date: Thu, 01 Jun 2000 19:10:08 +0000
Subject: Re: Global variable unset in function
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-20009@lists.php.net to get a copy of this message
On Thu, 1 Jun 2000, Joey wrote: > As was reported in the bug, use unset($GLOBALS["var"]). Can this method also be used with PHP3? Steve Langasek postmodern programmer > Here's why: > function f() > { > global $t; > // bind local $t to global $t > unset($t); > // break global binding > $t = "anything"; > // $t is on a local var, and will go out of scope at > // function end > } > $t = "something"; > f(); > print $t; > // We never changed the globally scoped copy of $t > // so we get "something"

« previous php.dev (#20009) next »