开发者

Why can non static member function be called this way? [duplicate]

This question already has answers here: Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜