title: Accessing Parent Class' property from child
body: <p>See the following example (PHP)</p>
  
  <pre><code>class Parent
  { 
    protected $_property;
    protected $_anotherP;
  
    public function __construct($var)
    {
      $this-&gt;_property = $var;
      $this-&gt;someMethod();  #Sets $_anotherP
    }
  
    protected function someMethod()
    ...
  }
  
  class Child extends Parent
  {
    protected $parent;
  
    public function __construct($parent)
    {
      $this-&gt;parent = $parent;
    }
  
    private function myMethod()
    {
      return $this-&gt;parent-&gt;_anotherP;  #Note this line
    }
  }
  </code></pre>
  
  <p>I am new to OOP and am a bit ignorant.</p>
  
  <p>Here to access the parents property I am using an instance of that class, which seems wrong :S (no need of being i child then). Is there an easy way, so that i can sync the parent properties with the child properties and can directly access $this->anotherP without having to use $this->parent->anotherP ?</p>