|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-03-06 15:24 UTC] moriyoshi@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 15:00:01 2025 UTC |
I have a problem when using two-way references. The simplest case I could dig out: <pre> class B { var $a; function B(& $a) { $this->a = & $a; } } class A { var $b; function A() { $this->b = & new B($this); } } $a = new A(); $a->x = "ax"; print $a->b->a->x; <pre> I think this should print out "ax". However it doesn't. If I add the following line after constructing $a: $a->b->a = &$a; then it works, it prints out "ax". Or, if I define A like this: <pre> class A { var $b; function A() { $this->b = & new B($this); } function setBsA() { $this->b->a = & $this; } } </pre> and call setBsA() after contructing, it still works.