核心代码
//魔术方法__call
/*
$method 获得方法名
$arg 获得方法的参数集合
*/
class Human {
private function t(){
}
public function __call($method,$arg){
echo '你想调用我不存在的方法',$method,'方法<br/>';
echo '还传了一个参数<br/>';
echo print_r($arg),'<br/>';
}
public static function __callStatic($method,$arg){
echo '你想调用我不存在的',$method,'静态方法<br/>';
echo '还传了一个参数<br/>';
echo print_r($arg),'<br/>';
}
}
$ha = new Human();
//example1
$ha->t(1,2,3);
echo '<br>';
//example2
$ha->say('a','b','c');
echo '<br>';
//example3
$ha::run('d','e','f');
你想调用我不存在的方法t方法
还传了一个参数
Array ( [0] => 1 [1] => 2 [2] => 3 )
你想调用我不存在的方法say方法
还传了一个参数
Array ( [0] => a [1] => b [2] => c )
你想调用我不存在的run静态方法
还传了一个参数
Array ( [0] => d [1] => e [2] => f )
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎点击右下角反馈进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。