Parameter passing in call_user_func_array
The following two lines are output:
Array (3) {[0] => string (3) "123" [1] => int (234) [2] => string (3) "fd "}
String (3) 123"
Why is the output of $ p not the entire array, but a string (3) "123 "? I read this manual:
Mixed call_user_func_array (callable $ callback, array $ param_arr)
Param_arr: The parameters to be passed to the callback, as an indexed array.
That is to say, the associated array will be passed.
Reply to discussion (solution)
For your code
Call_user_func_array ('B', $ p );
The actual execution is
B ('123', 123, 'cdg ')
That is, three parameters are passed to function B.
Function B ($ p) declares only one form parameter $ p.
So you can directly access var_dump ($ p) in the function; // 123
I have just read other examples and understood. Thank you, Xu
Function (){
$ P ['asdf '] = '000000 ';
$ P ['dfd '] = 234;
$ P ['hj3'] = 'cdg ';
Call_user_func_array ('B', array ($ p ));
}
Function B ($ p ){
$ P2 = func_get_args ();
Var_dump ($ p2 );
Var_dump ($ p );
}
A ();
?>