What is the good example of using 'func_get_arg' in PHP?

后端 未结 7 1153
梦谈多话
梦谈多话 2021-02-07 00:39

I just have found out that there is a function called func_get_arg in PHP which enables developer to use variant style of getting arguments. It seems to be very us

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 01:02

    Gets an array of the function's argument list.

    This function may be used in conjunction with func_get_arg() and func_num_args() to allow user-defined functions to accept variable-length argument lists.

    = 2) {
                    echo "Second argument is: " . func_get_arg(1) . "\n";
                }
                $arg_list = func_get_args();
                for ($i = 0; $i < $numargs; $i++) {
                    echo "Argument $i is: " . $arg_list[$i] . "\n";
                }
            }
    
            foo(1, 2, 3);
    ?>
    

提交回复
热议问题