See Ucenter when there is a function call_user_func, think not its solution, because I thought it is the function of their own definition, the results can not be found everywhere, and then Baidu a bit to know Call_user_func is built-in function, This function allows the user to call directly write functions and pass in a certain parameter, is not very powerful, summarize, write to this log inside it.
Let's start with someone else's example:
The Call_user_func function is similar to a particular method of calling a function, using the following method:functionA$b,$c) { Echo $b; Echo $c; } Call_user_func(' A ', "111", "222"); Call_user_func(' A ', "333", "444"); //Show 111 222 333 444?>calling the method inside the class is rather strange, actually using an array, do not know how developers think, of course, save new, is full of innovative:classa {functionb$c) { Echo $c; } } Call_user_func(Array("A", "B"), "111"); //Show 111?>The Call_user_func_array function is similar to the Call_user_func, except that the parameter is passed in a different way, making the structure of the parameter clearer .:functionA$b,$c) { Echo $b; Echo $c; } Call_user_func_array(' A ',Array("111", "222")); //Show 111 222?>The Call_user_func_array function can also invoke methods within the class .ClassClassA {functionbc$b,$c) { $BC=$b+$c; Echo $BC; } } Call_user_func_array(Array(' ClassA ', ' BC '),Array("111", "222")); //Show 333?>both the Call_user_func function and the Call_user_func_array function support references, which makes them more functionally consistent with normal function calls:functionA$b) { $b++; } $c= 0; Call_user_func(' A ',$c); Echo $c;//showing 1Call_user_func_array(' A ',Array($c)); Echo $c;//showing 2
Also: the Call_user_func function and the Call_user_func_array function all support references.
<?php
function increment (& $var)
{
$var + +;
}
$a = 0;
Call_user_func (' increment ', $a);
echo $a; 0
Call_user_func_array (' Increment ', array (& $a)); can use this instead
echo $a; 1
?>
Methods for invoking user-defined functions in PHP: Call_user_func,call_user_func_array