Home > Backend Development > PHP Problem > How to pass variable parameters in php

How to pass variable parameters in php

coldplay.xixi
Release: 2023-03-06 08:56:01
Original
2559 people have browsed it

php method of passing indefinite parameters: You can use the function [func_get_args] to implement, the code is [$args = func_get_args();for($i=0;$i

How to pass variable parameters in php

php variable parameter passing method:

Function func_get_args, func_num_args Can be achieved

<?php
    function more_args(){
        $args = func_get_args();
        for($i=0;$i<func_num_args();$i++){
            $a = $i +1;
            echo "第".$a."个参数是".$args[$i]."<br>";
        }
    }
    more_args(&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;,&#39;e&#39;,&#39;f&#39;);
?>
Copy after login

If you want to know more about programming learning, please pay attention to the php training column!

The above is the detailed content of How to pass variable parameters in php. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template