我有两个功能.其中之一接收和修改通过引用传递的数组中的一些值.
function dostuff ($param1, $param2, &$arr) {
//...
//add new elements to $arr
}
另一个是类中的方法,它包装了第一个方法:
class Wrapper
{
public function foo (...$args) {
return dostuff(...$args);
}
}
但是,如果我将数组传递给‘foo’,则数组保持不变.
我试图用&
来声明foo(... &$args)
,但这导致了一个语法错误.
在PHP中使用Splat运算符时,有没有办法通过引用传递参数?