Home > Article > Backend Development > php variable parameters
PHP Variable Parameters
php can also declare functions that accept a variable number of parameters. Through three helper functions, func_num_args(), func_get_arg() and func_get_args().
<?php function var_args(){ $args = func_get_args(); foreach($args as $arg){ echo $arg,'<br/>'; } echo 'the num arguments of function is:',func_num_args(); } var_args('hahah','lala','ddd');
The above introduces the PHP variable parameters, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.
Related articles:
php How to pass each element of the array as an actual parameter of a variable parameter function?
The difference between JS and PHP in passing variable parameters to functions. Example code