PHP之call_user_func_array用法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
header('Content-Type:text/html;charset=utf-8');
class call_func{
function func0() {
echo 'func0';
}

function func1($a) {
echo $a;
}

function func2($a, $b) {
echo $a+$b;
}

function func3($a, $b, $c) {
echo $a+$b+$c;
}
}

function otest() {
$args = func_get_args();
$num = func_num_args();
call_user_func_array(array('call_func','func'.$num), $args);
}

otest(1,1,1);

mixed call_user_func_array ( callback function, array param_arr ) 和 mixed call_user_func ( callback $function [, mixed $parameter [, mixed $… ]] ) 相似