Re: PHP 4.0 Bug #8378: unsetting a global array
| From: | Cynic | Date: | Fri, 22 Dec 2000 19:12:09 +0000 |
| Subject: | Re: PHP 4.0 Bug #8378: unsetting a global array | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-42130@lists.php.net to get a copy of this message | ||
this was explained just yesterday by Zeev Suraski:
function unsetArray()
{
global $array;
unset($array);
}
local $array variable referencing global $array is created in
this function. when you unset $array, you unset the _local_
$array, breaking the reference only. global $array still exists.
unset( $GLOBALS['array'] ) unsets $array in the global namespace.
that is not a bug, that's how it works.
At 19:57 22.12. 2000, superfly@jocose.net wrote the following:
--------------------------------------------------------------
>From: superfly@jocose.net
>Operating system: RedHat 7.0
>PHP version: 4.0.3pl1
>PHP Bug Type: Arrays related
>Bug description: unsetting a global array
>
><?
> function unsetArray()
> {
> global $array;
> unset($array);
> }
>
> $array[0] = "foo";
> $array[3] = "bar";
> unsetArray();
> $array[1] = "new";
> $array[2] = "data";
>?>
>
>This will set $array up like this:
>$array[0] = "";
>$array[1] = "new";
>$array[2] = "data";
>$array[3] = "";
>
>However:
><?
> function unsetArray()
> {
> unset($GLOBALS["array"]);
> }
>
> $GLOBALS["array"][0] = "foo";
> $GLOBALS["array"][3] = "bar";
> unsetArray();
> $GLOBALS["array"][1] = "new";
> $GLOBALS["array"][2] = "data";
>?>
>will set up an array like this:
>
>$array[1] = "new";
>$array[2] = "data";
>
>
>--
>Edit Bug report at: http://bugs.php.net/?id=8378&edit=1
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz