title: PHP class property reference to an object
body: <pre><code>class Hello {
      public function hi() {
          echo "Hello, hi!\n";
      }
  }
  
  class ParentClass {
      public $obj;
      public function __construct() {
         $this-&gt;obj = new Hello;
      }
  }
  
  class Test extends ParentClass {
       public function __construct() { 
          $this-&gt;obj-&gt;hi();
       }
  }
  
  $temp = new Test;
  </code></pre>
  
  <p>The error message I get is "Call to a member function hi() on a non-object". $obj should  be referencing to an instance of the class "Hello", but it obviously is not - what am I doing wrong? </p>