KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
is there a way to traverse an object to get the parent object data? With "parent object" I don't mean the parent class, but literally object. Here an example, in a javascripty world :-) : $parent->test = "hello world!"; $parent->child = new B(); It would be great If I could access all the data from parent in the child object: class B{ //I know this doesn't exists, but it's what I wanted do do function B(){ $this->parent = $this->parent(); echo $this->parent->test; //it would ouput "hello world" } } For now my solution is to pass the parent object to the child (as a reference) or to make the parent global. Do you have any better solution? Thanks!
Tags (comma-separated)
Save Edits
Cancel