The simplest way to input an indefinite number of parameters in a php function is to input an array. the number of array values can be unlimited.
How to input an indefinite number of parameters to a php function?
I think there are two methods.
The simplest way is to input an array. the number of array values can be unlimited.
Another method is to use func_get_args to obtain parameters.
Function args ($ SQL) {$ args = func_get_args (); array_shift ($ args); var_dump ($ SQL ); // 'all arguments in one array' syntax if (isset ($ args [0]) and is_array ($ args [0]) {$ args = $ args [0];} var_dump ($ args);} args ($ SQL = 1, $ query = 3, $ db = 'Lee '); args (array ('SQL' => 1, 'query' => 3, 'DB' => 'Lil '));
The output of the input parameter is as follows:
Int (1) array (2) {[0] => int (3) [1] => string (3) "lee"} array (3) {["SQL"] => int (1) ["query"] => int (3) ["db"] => string (3) "lee"} array (0 ){}