Php deep learning Note 2 (built-in function) 1. call _? User _? Func _? Array calls user-defined functions. The first parameter is the function name, and the second parameter is that the function parameter must be an index array functionfoobar ($ arg, $ arg2) {echo _ FUNCTION __, & quot; got $ argand $ arg2n & quot;} in-depth study Note 2 (built-in FUNCTION)
1. call _? User _? Func _? Array calls a user-defined function. The first parameter is the function name,
The second parameter is that the function parameter must be an index array.
Function foobar ($ arg, $ arg2) {echo _ FUNCTION __, "got $ arg and $ arg2 \ n";} class foo {function bar ($ arg, $ arg2) {echo _ METHOD __, "got $ arg and $ arg2 \ n" ;}}// call call_user_func_array ("foobar", array ("one ", "two"); // class member function call $ foo = new foo; call_user_func_array (array ($ foo, "bar"), array ("three ", "four "));
2. call _? User _? Reference parameters cannot be passed in function parameters called by func.
Call_user_func (function name, parameter 1, parameter 2 ...)
call_user_func(function($arg) { print "[$arg]\n"; }, 'test');
3. create _? Function to create an anonymous function
$ Myfunc = create _? Function ('function parameters', 'function body ');
$ Myfunc (function parameter );
$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');echo "New anonymous function: $newfunc\n";echo $newfunc(2, M_E) . "\n";
4. forward _? Static _? Call _? Array calls a static function in the same way as call_user_func_array
5. forward _? Static _? Call calls a static function in the same way as call_user_func.
6. func _? Get _? Arg (index) returns an index value for a parameter in the parameter list.
7. func _? Get _? Args collects all parameters in array form
8. func _? Num _? Args () returns the number of parameters passed by the function.
9. function _? Exists
Check whether a function exists
Function _? Exists ("function name"); // checks whether a function exists.
10. get _? Defined _? Functions returns all defined functions in a two-dimensional array.
Including system functions (internal)
And user-defined functions (user)
Array( [internal] => Array ( [0] => zend_version [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen [5] => strcmp [6] => strncmp ... [750] => bcscale [751] => bccomp ) [user] => Array ( [0] => myrow ))
11. register _? Shutdown _? Function the function registered by the function. when the system executes a Fatal error that exceeds the maximum time
The registered function will still be executed.
function add(){ code here... } register_?shutdown_?function("add");