我想从函数中获取所有参数(通过或不通过).
例:
<?php
function foo($a, $b=1)
{
return $a-$b;
}
?>
Run Code Online (Sandbox Code Playgroud)
如果我打电话
$test = func_get_args(foo(10));
var_dump($test);
Run Code Online (Sandbox Code Playgroud)
我将只有一个数组[0] => 10.
即使我没有传递它/它们,我如何获得可选参数的值?(我知道func_get_args只返回传递的参数.)
编辑:更确切地说,这就是我正在做的事情:
function insertLog($fct_name="-1", $type="-1", $error="-1", ....)
{
// first thing
$params = func_get_args();
var_dump($params);
}
Run Code Online (Sandbox Code Playgroud) php ×1