PHP function of the variable parameter list can be achieved by three functions _get_args (), func_num_args (), func_get_arg (). Below this we made a detailed introduction.
AD: 2014WOT Global Software Developer Forum Beijing station program video released
Perhaps for PHP junior programmer for PHP functions are not fully skilled master. Implementation of variable argument lists PHP functions we introduce today is mainly the use of func_get_args (), func_num_args (), func_get_arg () function to achieve the three systems, in which func_get_args () function to get the list of arguments as an array specific usage see the manual.
PHP function of the variable parameter list code is as follows:
- < ?php
- /**
- * Multi function parameter list
- *
- */
- function multiArgs()
- {
- / ** Returns the list of arguments as an array * /
- $args = func_get_args();
- Number / parameter ** * /
- $args_num = func_num_args();
- foreach ( $args as $key => $value )
- {
- echo 'This is ',$key+1,'th argument:',$value,'<br/>';
- }
- echo 'Number of args is ',$args_num;
- }
- multiArgs('one','two','three');
- /** output */
- /**
- This is 1th argument:one
- This is 2th argument:two
- This is 3th argument:three
- Number of args is 3
- */
- ?>
These are related to implementation of variable argument lists PHP functions.
Reproduced in: https: //www.cnblogs.com/zhangchenliang/p/3938342.html