This question already has an answer here:
Please review below code. Though I have not define test method as static It can be access by A::test(). How it is possible? Is it bug in PHP?
class A {
public function test(){
echo __CLASS__;
}
}
A::test(); //Print 'A'
If I try to access any public member inside test() method, It is giving me an error. See below.
class A {
public $name = 'jimit';
public static function test(){
echo $this->name;
echo __CLASS__;
}
}
A::test(); //Error
Please help me out to clarify the things.
Thanks, Jimit
</div>