title: Child Class editing Parent Class Property
body: <p>I've looked at similar questions like this, and none of the solutions offered within them seems to answer my question.</p>
  
  <p>This is the code I have so far (just learning OOP):</p>
  
  <pre><code>&lt;?php
  
  class page {
      var $ot;
      function begin(){
          $this-&gt;ot = '';
      }
      function finish(){
          echo $this-&gt;ot;
      }
  
  
  class forms extends page {
      function __construct($form_action, $form_type){
          $this-&gt;ot .= '&lt;form action=' . $form_action . ' method=' . $form_type . ' /&gt;';
      }
      function create_input($type, $name){
          $this-&gt;ot .= '&lt;input type="' . $type . '" name="' . $name . '" /&gt;&lt;br /&gt;';   
      }
      function create_submit($value){
          $this-&gt;ot .= '&lt;input type="submit" value="' . $value . '" /&gt;';
      }
      function __destruct(){
          $this-&gt;ot .= '&lt;/form&gt;';
      }       
  }
  
  class labels extends page {
      function create_label($label){
          $this-&gt;ot .= '&lt;label&gt;' . $label . ' &lt;/label&gt;';
      }
  }
  
  $page = new page();
  $page-&gt;begin();
  
  $newform = new forms('/class_lib.php', 'GET');
  $newlabels = new labels();
  
  $newlabels-&gt;create_label('Username:');
  $newform-&gt;create_input('text', 'username');
  $newlabels-&gt;create_label('Password:');
  $newform-&gt;create_input('password', 'password');
  
  $page-&gt;finish();
  
   ?&gt;
  </code></pre>
  
  <p>For some reason, this code does not output anything to the browser. However, if I change the child classes <em>forms</em> and <em>labels</em> to echo their output instead of storing it in the parent variable the code seems to spring to life and works as intended.</p>
  
  <p>Excuse my ignorance as I am new to OOP.</p>
  
  <p>Thanks!</p>