Bug #14626 Updated: calling a method "magically" turns the object into a reference to itself

From: Date: Sat, 01 Jun 2002 13:55:24 +0000
Subject: Bug #14626 Updated: calling a method "magically" turns the object into a reference to itself
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-9061@lists.php.net to get a copy of this message
ID: 14626 Updated by: mfischer@php.net Reported By: ivan.lamouret@novitek.fr -Status: Open +Status: Closed Bug Type: Class/Object related Operating System: linux Suse PHP Version: 4.1.0 New Comment: The expected behaviuor for ZE2 will be that $foo[0]->my_var == $new[0]->my_var == 'new'. The arrays are different but they contain one and the same object. Previous Comments: ------------------------------------------------------------------------ [2001-12-20 11:27:52] ivan.lamouret@novitek.fr Calling an object's method turn the object into a reference to itself. When the object is itself an array's value (or an object's instance variable) this shows up when copying (with simple assignement) the surrounding array (or object). class bar{ var $my_var = 'bar'; function buggy(){/*nothing needed here*/} } $foo[0] = new bar(); $foo[0]->buggy(); // turns the array's value into a reference to the object $new = $foo; $new[0]->my_var = 'new'; echo $foo[0]->my_var;// echoes 'new' !! Comment out the call to buggy(), or use var_dump before and after this call to see the magic transformation of $foo[0] from object(bar) to &object(bar). Tested with 4.0.3 and 4.1. The same bug has been reported under #11543 (open but unanswered). The code above is much simpler than that in the original bug report. (I could not edit that one :)) best regards Ivan ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=14626&edit=1

« previous php.bugs (#9061) next »