My code is like below:
<?php
class ClassName {
private $data = null;
public function __construct($data) {
$this->data = $data;
}
public static function staticFun ($data) {
echo $this->anotherFun($data);
}
private function anotherFun ($data) {
return $this->data;
}
}
?>
I am trying to call ClassName::staticFun('nilya'); as staticFun is a static function but I get Fatal error: Using $this when not in object context error. I know the distinction between static and non-static methods and how to call them but, in above code the given error occurs.
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?
Thanks in advance!
$thiswith something else.