在 PHP 函数中使用数组作为默认参数
是否可以在 PHP 函数中使用数组作为默认参数?
我想执行以下操作:
$arr = array(1,2,3,4);
function sample($var1, $var2, $var3 = $arr){
echo $var1.$var2;
print_r($var3);
}
sample('a','b');
// Should still work without the third parameter and default to $arr