call_user_func_array-Let arguments call a function in the form of an array
call_user_func-call a function that exists
create_function-Create a function
Func_get_arg-gets the value of a parameter in a function
func_get_args-get all the parameters of a function and make up an array
Func_num_args-gets the number of arguments for a function
function_exists-determine if a function exists
get_defined_functions-getting the existing function information
register_shutdown_function-registers a function that runs after a page is loaded and completed
register_tick_function-registering a function called on demand
unregister_tick_function-cancel a function called on demand
Get_defined_functions can get all the PHP functions and custom functions:
function A () {}
$b = Get_defined_functions ();
Print_r ($b);
More than 1000 defined functions may be displayed:)
?>
The Function_exists function determines whether a function exists (it can be a PHP function or a custom function).
if (function_exists (' a ')) {
echo "Yes";
} else {
echo "No";
}
function A () {}
Show Yes
?>
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
?>
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
?>
The Func_num_args function can get the number of arguments that the function accepts:
function A ()
{
Echo Func_num_args ();
}
A (111, 222, 333);
Showing 3
?>
The Func_get_arg function can get the value of a passed parameter, in the following example, the function does not specify which parameters are accepted, and the Func_get_arg can be used to obtain additional parameters:
function A ()
{
echo Func_get_arg (1);
}
A (111, 222, 333);
Showing 222
?>
- Total 2 Pages:
- Previous page
- 1
- 2
- Next page
http://www.bkjia.com/PHPjc/364290.html www.bkjia.com true http://www.bkjia.com/PHPjc/364290.html techarticle Call_user_func_array Let the parameter call a function in the form of an array call_user_func call an existing function Create_function establish a function Func_get_arg get a parameter in the function ...