ID:               39728
 Updated by:       [EMAIL PROTECTED]
 Reported By:      victorepand at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Unix
 PHP Version:      5.2.0
 New Comment:

"$GLOBALS - Contains a reference to every variable which is currently
available within the global scope of the script. The keys of this array
are the names of the global variables." (c)
http://www.php.net/manual/en/language.variables.predefined.php

With unset($GLOBALS['varname']); you unset the reference, not the
variable itself, which is equal to:
<?php
$var = "string";
$ref =& $var;
unset($ref); //unset the reference
var_dump($var); //but the $var is still here
?>


Previous Comments:
------------------------------------------------------------------------

[2006-12-04 12:04:52] victorepand at hotmail dot com

Description:
------------
When trying to unset a 2 dimensional array from within a function like
this (PHP 5.1):
   unset($GLOBALS["products"]);
elements like $products[123]["id"] continue to exist!

I had to use this command to unset the entire array, which is very
inefficient:
   foreach($products AS $their_product_id=>$ar)
unset($GLOBALS["products"][$their_product_id]);


Reproduce code:
---------------
unset($GLOBALS["products"]);

Expected result:
----------------
elements like $products[123]["id"] should no longer exist.

Actual result:
--------------
Elements like $products[123]["id"] continue to exist.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39728&edit=1

Reply via email to