开发者

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

开发者 https://www.devze.com 2023-02-04 06:11 出处:网络
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 ?!
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

精彩评论

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