有没有办法获得提供给php函数的参数?

Div*_*com 0 php

有没有办法将参数传递给php函数?

如果可能的话填写空白:

function foo(){
    var_dump( SOME_MAGICAL_FUNCTION_THAT_GETS_ALL_PARAMETERS_INTO_AN_ARRAY );
}
foo('a', 'b', 'c', 1, 2, 3);
Run Code Online (Sandbox Code Playgroud)

use*_*426 5

是的,使用PHP的内置函数func_get_args()

以下是PHP文档中的示例:

function foo()
{
    $numargs = func_num_args();
    echo "Number of arguments: $numargs<br />\n";
    if ($numargs >= 2) {
        echo "Second argument is: " . func_get_arg(1) . "<br />\n";
    }
    $arg_list = func_get_args();
    for ($i = 0; $i < $numargs; $i++) {
        echo "Argument $i is: " . $arg_list[$i] . "<br />\n";
    }
}

foo(1, 2, 3);
Run Code Online (Sandbox Code Playgroud)