title: How to call a non-static method from a static function in a class in php
body: <p>My code is like below:</p>
  
  <pre><code>&lt;?php
  
      class ClassName {
          private $data = null;
              public function __construct($data) {
              $this-&gt;data = $data;
          }
          public static function staticFun ($data) {
              echo $this-&gt;anotherFun($data);
          }
          private function anotherFun ($data) {
              return $this-&gt;data;
          }
      }
  
  ?&gt;
  </code></pre>
  
  <p>I am trying to call <code>ClassName::staticFun('nilya');</code> as <code>staticFun</code> is a static function but I get <code>Fatal error: Using $this when not in object context</code> error. I know the distinction between static and non-static methods and how to call them but, in above code the given error occurs.</p>
  
  <p>Is it possible to call a non-static method in a static method? If not how should the code be modified to make it work?</p>
  
  <p>Thanks in advance!</p>