// === 代码部分__call === //
class Human {
public function hello() {
echo 'hello<br >';
}
private function t() {
}
public static function __callStatic($method,$arguments) {
echo '你想调用一个我不存在或无权调用的静态方法',$method,'<br >';
echo '你调用时还传了参数<br >';
print_r($arguments);
}
public function __call($method,$arguments) {
echo '你想调用一个我不存在或无权调用的方法',$method,'<br >';
echo '你调用时还传了参数<br >';
print_r($arguments);
}
}
$lisi = new Human();
$lisi->hello(); // hello
$lisi->say(1,2,3);
/*
你想调用一个我不存在的方法say
你调用时还传了参数
Array ( [0] => 1 [1] => 2 [2] => 3 )
*/
echo '<br >';
$lisi->t('a','b','c');
/*
你想调用一个我不存在或无权调用的方法t
你调用时还传了参数
Array ( [0] => a [1] => b [2] => c )
*/
// === 笔记部分__call === //
/*
__call是可调用不可见(不存在或无权限的方法时),自动调用
$lisi->say(1,2,3) — 没有say()方法 — __call(‘say’,array(1,2,3))运行
*/
Human::cry('痛哭','号哭','鬼哭');