call_user_func_array使用场景
第一种调用函数
function sayChinese($func_name, $content){
echo "说中文:".$content."<br>";
}
function sayEnglish($func_name, $content, $msg){
echo "say English:".$content."msg:".$msg;
}
function say(){
$args = func_get_args();
//var_dump($args);
call_user_func_array($args[0], $args);
}
//say('sayChinese', '我叫张正山');
say('sayEnglish', 'my name is zzs','but chinese is very good!');
第二种静态方法
class article {
public static function sayChinese($content, $country) {
echo $content.$country;
}
}
function say() {
$args = func_get_args();
call_user_func_array(array('article', 'sayChinese'), $args);
//call_user_func_array('article::sayChinese', $args);
}
say('fuck',' you');