使用splat运算符解压缩数组参数,就像在函数中使用一样:
原文链接:https://www.f2er.com/php/240062.htmlselectAll($str,...$arr);
像这样:
function selectAll(string $sql,...$params) { print_r(func_get_args()); } $str = "This is a string"; $arr = ["First Element","Second Element",3]; selectAll($str,...$arr);
打印:
Array ( [0] => This is a string [1] => First Element [2] => Second Element [3] => 3 )
Eval为此.
如果您不在参数中使用splat运算符,则最终将结束like this