|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-10-05 17:51 UTC] stas@php.net
[2000-12-06 16:56 UTC] waldschrott@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 02:00:01 2025 UTC |
This bug appeared when I installed php4.0.2, I had php4.0.1RC before. I'm trying to add a reference to Parent to each Child as its created. It seems like the Parent->baseObj property cannot be a reference to $this, its instance. An example of the code that caused the problem: <? class Parent { function Parent(){ $this->baseObj = &$this; } function insert($name){ /* This will work if(get_class($this) == 'parent'){ $this->test[$name] = new Child(); $this->test[$name]->baseObj = &$this; } else { $this->baseObj->test[$name] = new Child(); $this->baseObj->test[$name]->baseObj = &$this->baseObj; } /* /* This will not - says error: call to member function on non-object */ $this->baseObj->test[$name] = new Child(); $this->baseObj->test[$name]->baseObj = &$this->baseObj; } } class Child extends Parent{ function Child(){ $this->whatever = 'sometext'; } function showMe(){ echo "I exist"; } } $obj = new Parent(); $obj->insert('foo'); $obj->test['foo']->insert('bar'); $obj->test['bar']->insert('blah'); $obj->test['foo']->showMe(); $obj->test['bar']->showMe(); $obj->test['blah']->showMe(); ?>