Call_user_func_array
(PHP 4 >= 4.0.4, PHP 5)
Call_user_func_array--Call a user function given with an array of parameters
Description
Mixed Call_user_func_array (callback function, array Param_arr)
Call a user defined function given by function with the parameters in Param_arr. For example:
Example 1. Call_user_func_array () example
Copy the Code code as follows:
function Debug ($var, $val)
{
echo "***debugging\nvariable: $var \nvalue:";
if (Is_array ($val) | | is_object ($val) | | is_resource ($val)) {
Print_r ($val);
} else {
echo "\n$val\n";
}
echo "***\n";
}
$c = mysql_connect ();
$host = $_server["SERVER_NAME"];
Call_user_func_array (' Debug ', Array ("host", $host));
Call_user_func_array (' Debug ', Array ("C", $c));
Call_user_func_array (' Debug ', Array ("_post", $_post));
?>
Copy the Code code as follows:
function test ($STR) {
Echo $str;
}
Call_user_func_array ("Test", "www.chhua.com");//Output "www.chhua.com"
Parameter description "The first parameter is the function name, the second is the parameter
Class TestClass {
Public function Write ($STR) {
Echo $str;
}
}
Call_user_func_array (Array (testclass,write), "www.chhua.com");//When using the class call, use Array (), Array (class name, method name)
?>
The above describes the PHP Call_user_func_array function usage demonstration, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.