title: Access parent class properties from child class that have been set by parent constructor in PHP
body: <p>OK, I'm having a bit of a problem. Here's the scenario:
  I need to be able to get the constructor of test2 to be able to access the class property test that is inside main_class that has been set by main_class' constructor. I'm not sure how to get it to work, and I need the system to work like exactly like this. Now, this WOULD work if I set the class variable in the code, like this <code>var test = "hello";</code> in the class definition, but of course in this case, main_class::test is set by it's constructor and is not a "var", so it doesn't work.</p>
  
  <p>Here is a highly simplified version of my code:</p>
  
  <p>index.php:</p>
  
  <pre><code>&lt;?php
  
  class main_class
  {
      private $test2;
      public function __construct()
      {
          $this-&gt;test2 = array();
          include("./test1.php");
          $var_name = "test";
          $this-&gt;$var_name = new test1();
      }
  
      protected function do_include()
      {
          include("./test2.php");
          $this-&gt;test2["test2"] = new test2();
      }
  }
  
  $test = new main_class();
  
  ?&gt;
  </code></pre>
  
  <p>test1.php:
      
  
  <pre><code>class test1 extends main_class
  {
      public function __construct()
      {
          $this-&gt;do_include();
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>test2.php:
      
  
  <pre><code>class test2 extends test1
  {
      public function __construct()
      {
          print_r($this-&gt;test);
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>With this code, I get this error:
      Notice: Undefined property: test2::$test</p>
  
  <p>Thanks in advance...</p>