title: PHP class extends not working why and is this how to correctly extend a class?
body: <p>Hi so I'm trying to understand how inherteince works in PHP using object oriented programming. The main class is Computer, the class that is inheriting is Mouse. I'm extedning the Computer class with the mouse class. I use __construct in each class, when I istinate the class I use the pc type first and if it has mouse after. For some reason computer returns null? why is this?</p>
  
  <pre><code>class Computer {
      protected $type = 'null';
  
      public function __construct($type) {
          $this-&gt;type = $type;
      }
      public function computertype() {
          $this-&gt;type = strtoupper($this-&gt;type);
          return $this-&gt;type;
      }
  
  }
  
  class Mouse extends Computer {
      protected $hasmouse = 'null';
      public function __construct($hasmouse){
           $this-&gt;hasmouse = $hasmouse;
  
      }
      public function computermouse() {
           if($this-&gt;hasmouse == 'Y') {
               return 'This Computer has a mouse';
           }
      }
  
  }
  
  $pc = new Computer('PC', 'Y');
  echo $pc-&gt;computertype;
  echo $pc-&gt;computermouse;
  </code></pre>