call_user_func_array — Call a function with parameters in the form of an array
call_user_func — Call an existing function
create_function — Create a function
func_get_arg — Get the value of a parameter in the function
func_get_args — Get all the parameters of the function and form an array
func_num_args — Get the number of parameters of a function
function_exists — Determine whether a function exists
get_defined_functions — Get existing function information
register_shutdown_function — Register a page load Enter a function that runs after completion
register_tick_function — register a function that is called on request
unregister_tick_function — cancel a function that is called on request
get_defined_functions can get all PHP functions and custom functions:
function a(){}
$b = get_defined_functions();
print_r($b);
//may display more than 1000 defined function:)
?>
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(){}
// Display yes
?>
The call_user_func function is similar to a special method of calling a function. The method of use is as follows:
php
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
?>
It is strange to call the method inside the class, actually using is an array, I don’t know how the developers thought about it. Of course, new is omitted, which is also full of novelty:
class a {
function b($c)
{
echo $c;
}
}
call_user_func(array("a", "b"),"111");
//Display 111
?>
The call_user_func_array function is very similar to call_user_func, except that the parameters are passed in a different way to make the structure of the parameters clearer:
function a($b , $c)
{
echo $b;
echo $c;
}
call_user_func_array('a', array("111", "222"));
//Display 111 222
?>
Both the call_user_func function and the call_user_func_array function support references, which makes them more functionally consistent with ordinary 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
?>
func_num_args function can get the parameters accepted by the function Quantity:
function a()
{
echo func_num_args();
}
a(111, 222, 333);
//Display 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 will be accepted. You can also get it by using func_get_arg Additional parameters:
function a()
{
echo func_get_arg(1);
}
a (111, 222, 333);
//Display 222
?>