title: How do you set the value of a parent class variable in an inherited class but then use it in an inherited function?
body: <p>I have the following. Currently it doesn't output anything for &quot;$this-&gt;aa&quot;.
  I want to be able to inherit the class, set some variables, then call the parent class functions to act on it. Am I going about this the wrong way?</p>
  <pre><code>class A {
      private $aa;
  
      function __construct() {
         $this-&gt;aa = &quot;class a&quot;;
      }
  
      function parentmethod() {
         echo '['.$this-&gt;aa.']';
      }
  }
  
  class B extends A {
      function __construct() {
          $this-&gt;aa = &quot;class b&quot;;
      }
  
  }
  
  $test = new B();
  $test-&gt;parentmethod();
  </code></pre>