<?php
class T {
public function x(){
return true;
}
}
var_dump(T::x());
class X {
public function x(){
return true;
}
}
var_dump(X::x());
这段代码的结果是:
bool(true)
PHP Fatal error: Non-static method X::x() cannot be called statically in test.php on line 16
为什么T::x()能正常工作(实际上应该失败),而X::x()失败了(按照预期)?
well
,self
,parent
和static
也在进行非静态调用。你确定$x = T::x();
是成功的吗?! - bwoebierror_reporting(-1);
然后你就能看到它了(但也取决于你所使用的 PHP 版本)。 - bwoebi