ID: 21711 Updated by: [EMAIL PROTECTED] Reported By: klar at nm dot ru -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: WIN2000 PHP Version: 4.3.0 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php <? class foo { var $owner; function foo(&$owner) { $this->owner = &$owner; // the owner object needs to be assigned as a // reference here, instead of a copy. } } class bar { var $foo; function bar() { $this->foo = &new foo($this); } } $b = new bar(); var_dump($b->foo->owner->foo); ?> Previous Comments: ------------------------------------------------------------------------ [2003-01-17 07:14:34] klar at nm dot ru <? class class_root { var $a; var $b; function class_root() { echo get_class($this)." Created<br>"; } } class db_class extends class_root { var $owner; function db_class($ow) { $this->class_root(); $this->owner=$ow; } } class adm_class extends class_root { var $owner; function adm_class($ow) { $this->class_root(); $this->owner=$ow; } function kkk() { echo get_class($this->owner)."<br>"; echo get_class($this->owner->adm)."<br>";//Undefined ??? ... must be object echo get_class($this->owner->db)."<br>";//Undefined ??? ... must be object $this->owner->adm->kkk(); } } class super_class extends class_root { var $s; var $adm; var $db; function super_class() { $this->class_root(); $this->adm=new adm_class(&$this); $this->db=new db_class(&$this); } } $sc=new super_class(); $sc->adm->kkk(); echo '-------'; ?> results: super_class Created adm_class Created db_class Created super_class Fatal error: Call to a member function on a non-object in bla-bla-bla\1.php on line 35 PHP works as apache2 module ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21711&edit=1
