<?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() 失败(因为它应该)?