ID:               24630
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tater at potatoe dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: OS X 10.2
 PHP Version:      5.0.0b2-dev
 New Comment:

Try search the bug database before submitting new reports..
there are couple of related reports still open. (mostly documentation
issues..)



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

[2003-07-12 20:47:59] tater at potatoe dot com

Description:
------------
If you create an array by assigning its elements the value of a scalar
variable (or, in PHP5, by using array_combine() with an array of keys
and an array built with array_fill() or array_pad()), then
extract(array, EXTR_REFS) will make that scalar into a reference, as
well as making all the array elements references to the same...
location? I don't know, they all end up pointing to the same thing, so
that changing any one of them changes all of them.

This tests the same on the current PHP4 release and the latest CVS PHP5
code.


Reproduce code:
---------------
<?php
function trap()
{
    $tick = 0;
    $x = array('x1'=>$tick, 'x2'=>$tick, 'x3'=>0, 'x4'=>0);
    $y = array('y1'=>$tick, 'y2'=>$tick, 'y3'=>0, 'y4'=>0);
    var_dump(get_defined_vars());
    foreach ($x as $k => $v)
        $$k =& $x[$k];
    extract($y, EXTR_REFS);
    var_dump(get_defined_vars());
    $x1 = 1;
    $y1 = 2;
    $y3 = 4;
    var_dump(get_defined_vars());
    $tick = 5;
    var_dump(get_defined_vars());
}
trap();
?>

Expected result:
----------------
Changing $y1 should only change it and y['y1'].
Changing $tick should only change $tick.

Actual result:
--------------
Changing $y1 or $tick changes the other as well.


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


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

Reply via email to