I have below scenario, want to use specific method as static so can i use $this for other methods or not.
class foobar { public $foo; public function __construct() { global $foo; $this->foo = $foo; } public static function foobarfunc() { return self::foo(); } public function foo() { return $this->foo = 'hi'; } } echo foobar::foobarfunc(); ERROR:
Fatal error: Using $this when not in object context in
This is my scenario
class DB{ public function selectQuery(){ $data = $this->finddata(); return "SELECT $data FROM bhumi"; } public function finddata(){ $data = ('*'); return $data; } } class TP extends DB{ public static $create; public function __construct(){ $this->parentObj = new DB(); } public static function printQ(){ $d = parent::selectQuery(); return $d; } } echo TP::printQ(); How to do that? this code giving me error.