title: Why can't i call this protected function in PHP?
body: <p>This is probably a basic question but im following this tutorial and at one point the code looks something like this.</p>
  
  <pre><code>&lt;?php
  
  class person
  {
      public $name;
      public $height;
      protected $social_security_no;
      private $pin_number = 3242;
  
      public function __construct($person_name)
      {
          $this-&gt;name = $person_name;
      }
      public function set_name($new_name)
      {
          $this-&gt;name = $new_name;
      }
  
      protected function get_name()
      {
          return $this-&gt;name;
      }
  
      public function get_pin_number_public()
      {
          $this-&gt;pub_pin = $this-&gt;get_pin_number();
          return $this-&gt;pub_pin;
      }
  
      private function get_pin_number()
      {
          return $this-&gt;pin_number;
      }
  
  }
  
  class employee extends person
  {
  
      public function __construct($person_name)
      {
          $this-&gt;name = $person_name;
      }
  
      protected function get_name()
      {
          return $this-&gt;name;
      }
  }
  </code></pre>
  
  <p>However when i use this</p>
  
  <pre><code>&lt;?php include "class_lib.php";?&gt;
      &lt;/head&gt;
      &lt;body id="theBody"&gt;
      &lt;div&gt;
  
  &lt;?php
  $maria = new person("Default");
  
  $dave = new employee("David Knowler");
  echo $dave-&gt;get_name();
  ?&gt;
  </code></pre>
  
  <p>i get this error</p>
  
  <blockquote>
    <p>Fatal error: Call to protected method employee::get_name() from
    context '' in C:\Users\danny\Documents\Workspace\test\index.php on
    line 13</p>
  </blockquote>
  
  <p>The problem seems to be when i add protected to the get_name() function in the employee class but it seems to me that this is the preferred way to override in the tutorial. Any ideas?</p>