php variable parameters

PHP中文网
Release: 2023-02-28 22:08:02
Original
2504 people have browsed it

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;);
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template