ID:               40385
 Updated by:       [EMAIL PROTECTED]
 Reported By:      viqq at gazeta dot pl
-Status:           Open
+Status:           Bogus
 Bug Type:         Variables related
 Operating System: Linux ubuntu 2.6.15-27-386
 PHP Version:      5.2.0
 New Comment:

>$t[] = &$node
"$t[0] and $node both point to the same value".

>$node = '2';
"$node is changed to '2', $t[0] is changed either".

>$t[] = &$node;
"$t[1] points to the value already referenced by $node and $t[0]".


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

[2007-02-07 12:39:15] viqq at gazeta dot pl

Description:
------------
When a reference to a variable (containing e.g. a literal or an object)
is inserted into an array, all existing references in this array becomes
references to this variable.


Reproduce code:
---------------
$t = NULL;

$node = '1';
// or $node = new Object();
$t[] = &$node;

$node = '2';
// or $node = new Object();
$t[] = &$node;

var_dump($t);


Expected result:
----------------
array(2) {
  [0]=>
  &string(1) "1"
  [1]=>
  &string(1) "2"
}

Actual result:
--------------
array(2) {
  [0]=>
  &string(1) "2"
  [1]=>
  &string(1) "2"
}


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


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

Reply via email to