Bug #53525 [Opn->Bgs]: php version 5.3.0 - error in unset var for when used in function
| From: | cataphract@php.net | Date: | Sun, 12 Dec 2010 09:49:45 +0000 |
| Subject: | Bug #53525 [Opn->Bgs]: php version 5.3.0 - error in unset var for when used in function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156916@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53525&edit=1
ID: 53525
Updated by: cataphract@php.net
Reported by: shoja dot mehrdad at gmail dot com
Summary: php version 5.3.0 - error in unset var for when used
in function
-Status: Open
+Status: Bogus
Type: Bug
Package: Variables related
Operating System: test in windows vista
PHP Version: 5.3.4
Block user comment: N
Private report: N
New Comment:
Unset deletes the function local variable $array, not the global $b,
despite $array and $b being in the same reference set. This is by
design. When $array is recreated it already lost its connection to $b.
Note that $array and $b point to the same data, but $array doesn't
"know" which other variables (in this case,the global $b) point to this
same data its pointing, so it cannot really unset $b.
Previous Comments:
------------------------------------------------------------------------
[2010-12-12 09:27:41] shoja dot mehrdad at gmail dot com
Description:
------------
$b = array(1, 2, 3);
function b(&$array)
{
$array[0] = 1000;
unset($array); // <=====
$array = array();
$array[1] = 2000;
}
b($b);
print_r($b);
Test script:
---------------
Array
(
[0] => 1000
[1] => 2
[2] => 3
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53525&edit=1