When I try this :
<?php
class myParent {
public function __call($method, $params) {
echo "from __call";
}
public function __callStatic($method, $params) {
echo "from __callStatic";
}
}
class mySon extends myParent {
public function bar() {
myParent::foo();
}
}
(new mySon())->bar();
Run Code Online (Sandbox Code Playgroud)
I expect this output : from __callStatic ...
Instead it gives : from __call.
有人可以解释一下为什么吗?
编辑:确切地说,我想知道为什么如果删除该__call函数,它就会触发__callStatic,以及是否有办法__callStatic在__call声明时触发。