From: oracle16 at freemail dot hu Operating system: Windows PHP version: 4.3.1 PHP Bug Type: Class/Object related Bug description: Reference problem inside constructor
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. -- Edit bug report at http://bugs.php.net/?id=22443&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22443&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22443&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22443&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22443&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22443&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22443&r=support Expected behavior: http://bugs.php.net/fix.php?id=22443&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22443&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22443&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22443&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22443&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22443&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22443&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22443&r=gnused