From:             gomez at efrei dot fr
Operating system: windows and linux
PHP version:      4.3.2
PHP Bug Type:     Arrays related
Bug description:  $a = $b; become $a=&$b; when I use a function

Description:
------------
In an array, classes become classes references when I use a function
member.

Because of that, I don't copy it anymore, I just produce more  pointers to
it.
(see the '&' in the var dump)

If you comment the magic line, the bug won't appear.

Tested under linux (php 4.1.2 and 4.2.3)
and windows (php 4.3.2)

Reproduce code:
---------------
<?php
class AAAAA  {
    var $value;
    function AAAAA() {}
    function show() { return 5; }
}
$A = array(new AAAAA());
    $A[0]->show(); /* magic line */
$A[0]->value = 'A';
$B = $A;
$B[0]->value = 'B';
echo $A[0]->value.$B[0]->value;
echo "\n";
var_dump( $A );

?>

Expected result:
----------------
AB
array(1) {
  [0]=>
  object(aaaaa)(1) {
    ["value"]=>
    string(1) "A"
  }
}

Actual result:
--------------
BB
array(1) {
  [0]=>
  &object(aaaaa)(1) {
    ["value"]=>
    string(1) "B"
  }
}


-- 
Edit bug report at http://bugs.php.net/?id=24485&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24485&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24485&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24485&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24485&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24485&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24485&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24485&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24485&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24485&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24485&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24485&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24485&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24485&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24485&r=gnused

Reply via email to