1、__callStatic 没有影响对 test 的调用,**只要**方法中没有$this 伪变量,就可以通过双冒号访问。
只有当报错级别为 E_STRICT 时会报 warning,参考:
http://php.net/manual/zh/language.oop5.basic.php2,__callStatic 的作用不是看方法存不存在,而是有没有“权限”访问到。
> 在对象中调用一个不可访问方法时,__call() 会被调用。
> 在静态上下文中调用一个不可访问方法时,__callStatic() 会被调用。
参考:
http://php.net/manual/zh/language.oop5.overloading.php#object.callstatic目标方法非 public 时__callStatic 才会起作用。
```php
<?php
class A{
public static function __callStatic($name, $arguments)
{
echo "{$name}静态方法不存在!\n";
}
public function test()
{
echo "test 方法\n";
}
public static function test2()
{
echo "test2 方法\n";
}
private static function test3()
{
echo "test3 方法\n";
}
protected static function test4()
{
echo "test4 方法\n";
}
}
A::test();
A::test2();
A::test3();
A::test4();
```
刚刚现查的,大神们要是看出什么错误记得指出。