The following is a detailed analysis of the method of invoking user-defined functions in PHP, the need for friends can come to the reference
Let's take the example first:
The Call_user_func function is similar to a particular method of calling a function, using the following method:
function A ($b, $c) { echo $b; echo $c; } Call_user_func (' A ', "111", "222"); Call_user_func (' A ', "333", "444"); Display 111 222 333 444
Call the method inside the class is rather strange, incredibly using an array, do not know how developers think, of course, save new, is full of innovative:
Class A { function B ($c) { echo $c; } } Call_user_func (Array ("A", "B"), "111"); Showing 111
The Call_user_func_array function is similar to the Call_user_func, except that the parameter is passed in a different way, allowing the structure of the parameter to be clearer:
function A ($b, $c) { echo $b; echo $c; } Call_user_func_array (' A ', Array ("111", "222")); Showing 111 of 222
The Call_user_func_array function can also invoke methods within the class.
Class ClassA { function BC ($b, $c) { $BC = $b + $c; echo $bc; } } Call_user_func_array (Array (' ClassA ', ' BC '), Array ("111", "222")); Showing 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:
function A ($b) { $b + +; } $c = 0; Call_user_func (' A ', $c); echo $c;//display 1 call_user_func_array (' A ', Array ($c)); echo $c;//Display 2
Also: the Call_user_func function and the Call_user_func_array function all support references.
<?phpfunction Increment (& $var) { $var + +;} $a = 0;call_user_func (' increment ', $a); Echo $a; 0call_user_func_array (' Increment ', array (& $a)); Can use this insteadecho $a; 1?>