title: Parent Object in php
body: <p>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  :-) :</p>
  
  <pre><code>$parent-&gt;test = "hello world!";
  
  $parent-&gt;child = new B();
  </code></pre>
  
  <p>It would be great If I could access all the data from parent in the child object:</p>
  
  <pre><code>class B{
  
  //I know this doesn't exists, but it's what I wanted do do
      function B(){
          $this-&gt;parent = $this-&gt;parent();
          echo $this-&gt;parent-&gt;test; //it would ouput "hello world"
      }
  }
  </code></pre>
  
  <p>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?</p>
  
  <p>Thanks!</p>