PHP is rarely used but has powerful functions. Call_user_func_array calls a function call_user_func in the form of an array to call an existing function create_function to create a function func_get_arg to obtain the parameter call_user_func_array in the function. the parameter calls a function 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-registers a function that runs after a page is loaded.
Register_tick_function-registers a function called as required
Unregister_tick_function-cancels a function called as required
Get_defined_functions can get all PHP functions and custom functions:
Function (){}
$ B = get_defined_functions ();
Print_r ($ B );
// More than 1000 defined functions may be displayed :)
?>
The function_exists function determines whether a function exists (either a PHP function or a custom function ).
If (function_exists ('A ')){
Echo "yes ";
} Else {
Echo "no ";
}
Function (){}
// Display yes
?>
The call_user_func function is similar to a special method for calling a function. the usage is as follows:
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
?>
The internal method of calling the class is strange. the method actually uses an array and does not know how developers think about it. of course, the new method is saved, which is also innovative:
Class {
Function B ($ c)
{
Echo $ c;
}
}
Call_user_func (array ("a", "B"), "111 ");
// Display 111
?>
The call_user_func_array function is similar to call_user_func, but the parameter is passed in another way to make the parameter structure clearer:
Function a ($ B, $ c)
{
Echo $ B;
Echo $ c;
}
Call_user_func_array ('A', array ("111", "222 "));
// Display 111 222
?>
Call_user_func and call_user_func_array functions support reference, which makes them more functional than 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 obtain the number of parameters received by the function:
Function ()
{
Echo func_num_args ();
}
A (111,222,333 );
// Display 3
?>
The func_get_arg function can obtain the value of a passed parameter. in the following example, the function does not specify which parameters will be accepted, you can use func_get_arg to obtain additional parameters:
Function ()
{
Echo func_get_arg (1 );
}
A (111,222,333 );
// Display 222
?>
- 2 pages in total:
- Previous Page
- 1
- 2
- Next page
The http://www.bkjia.com/PHPjc/364290.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/364290.htmlTechArticlecall_user_func_array allows the parameter to call a function call_user_func in the form of an array to call an existing function create_function to create a function func_get_arg to get a parameter in the function...