ID: 26756 Updated by: [EMAIL PROTECTED] Reported By: tilman dot giese at gmx dot de -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Linux PHP Version: 4.3.4 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2003-12-31 10:10:21] tilman dot giese at gmx dot de Description: ------------ The problem is not that easy to explain. If you have two objects referencing each other, one of the references gets somehow lost. Look at the actual result, especially at the missing ampersands of object(test3)! Although I only use references in the script (sorry about it be longer than 20 lines) it seems that I get copies of the objects. Reproduce code: --------------- class Test1 { var $a; function Test1() { $this->a = new Test2(); } function &getTest2() { return $this->a; } } class Test2 { var $b; var $counter = 1; function Test2() { $this->b = new Test3($this); } function &getTest3() { return $this->b; } } class Test3 { var $p; function Test3(&$parent) { $parent->counter++; $this->p =& $parent; } function getCounter() { return $this->p->counter; } } $obj = new Test1(); $obj2 =& $obj->getTest2(); echo $obj2->counter; $obj2->counter++; $obj3 =& $obj2->getTest3(); echo $obj3->getCounter(); var_dump($obj); Expected result: ---------------- 23 object(test1)(1) { ["a"]=> &object(test2)(2) { ["b"]=> &object(test3)(1) { ["p"]=> &object(test2)(2) { ["b"]=> &object(test3)(1) { ["p"]=> &object(test2)(2) { ["b"]=> &object(test3)(1) { ["p"]=> *RECURSION* } ["counter"]=> int(3) } } ["counter"]=> int(3) } } ["counter"]=> int(3) } } Actual result: -------------- 22 object(test1)(1) { ["a"]=> &object(test2)(2) { ["b"]=> &object(test3)(1) { ["p"]=> &object(test2)(2) { ["b"]=> object(test3)(1) { ["p"]=> &object(test2)(2) { ["b"]=> object(test3)(1) { ["p"]=> *RECURSION* } ["counter"]=> int(2) } } ["counter"]=> int(2) } } ["counter"]=> int(3) } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26756&edit=1
