|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-08-12 09:29 UTC] rodif_bl@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
I have 2 classes linked together. In a search-method an object (or a list of them) is created and returned. The structure was build correct in the search-method, but when I assign another value to the mom-object it seams that there are different child-objects. The following sample shows it: #################################### # class Mom { // Properties: var $title; var $myChild; // Methods: function Mom ($title = "") { $this->title = $title; } function init (&$child) { $this->myChild = &$child; } function search () { $mom = new Mom ("test10"); $child = new Child (); $mom->init (&$child); $child->init (&$mom); return $mom; } } # end class Mom #################################### # class Child { // Properties: var $myMom; // Methods: function Child () { } function init (&$mom) { $this->myMom = &$mom; } } # end class Child #################################### # # test code: $m = new Mom (); $mom = $m->search (); $t0 = $mom->title; $t1 = $mom->myChild->myMom->title; echo "$t0 = $t1<br>\n"; # correct values $mom->title = "test1"; $t0 = $mom->title; $t1 = $mom->myChild->myMom->title; echo "$t0 != $t1<br>\n"; # why are t0 and t1 different? Is there a bug in my code or in php? Thanks, Chris