为什么这种方式可以调用非静态成员函数?

时间:2011-01-12 03:50:19

标签: php syntax

  

可能重复:
  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();

这是一个错误或功能吗?

1 个答案:

答案 0 :(得分:1)

显然这是允许的,但绝对气馁。 According to the manual

  

静态调用非静态方法会生成E_STRICT级警告。