title: Using $this when not in object context php
body: <p>I just started learning OOPS in php. I wrote a simple program for implementing inheritance. I am getting a fatal error of $this when not in object context. Can anyone explain me this error, what does it mean?
  here is my code:</p>
  
  <pre><code>&lt;?php
  
      class human{
  
          public $gender;
  
          public function _construct($gender)
          {
              $this-&gt;gender=$gender;
  
              echo $this-&gt;get_gender();
          }
  
          public function get_gender()
          {
              return $this-&gt;gender;
          }
  
  
      }
  
      class person extends human{
  
          public $name;
          public $surname;
  
          public static function set_name($name)
          {
              $this-&gt;name=$name;
          }
          public static function set_surname($surname)
          {
              $this-&gt;surname=$surname;
          }
  
          public static function get_name()
          {
              return $this-&gt;name;
          }
          public static function get_surname()
          {
              return $this-&gt;surname;
          }
      }
  
      $john = new person('male');
      $john-&gt;set_name('John');
      $john-&gt;set_surname('Williams');
      echo $john-&gt;get_name().' '.$john-&gt;get_surname().'is a '.$john-&gt;get_gender();
      ?&gt;
  </code></pre>