Home  >  Article  >  Backend Development  >  php variable parameters

php variable parameters

PHP中文网
PHP中文网Original
2017-03-22 16:17:342505browse

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,&#39;<br/>&#39;;
    }
    echo &#39;the num arguments of function is:&#39;,func_num_args();
}
var_args(&#39;hahah&#39;,&#39;lala&#39;,&#39;ddd&#39;);

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

php variable parameter implementation

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn