Why can non static member function be called this way? [duplicate]
Possible Duplicate:
PHP: call to an instance method via ClassName::method syntax, results in a static call ?!
class A
{
function foo()
{
if (isset($this)) {
echo '$this is defined (';
echo get_class($this);
echo ")\n";
开发者_开发百科 } else {
echo "\$this is not defined.\n";
}
}
}
A::foo();
Is this a bug or feature?
Apparently it's allowed, but definitely discouraged. According to the manual:
Calling non-static methods statically generates an E_STRICT level warning.
精彩评论