只有变量可以通过引用传递 - php
我正在尝试这段代码,但出现此错误:
Only variables can be passed by reference in xxx
脚本
class page {
function insert($db, $of, $form, &$arr) {
$i = 0;
foreach(array_combine($form['value0'], $arr) as $val=>$v){
$sql->prepare("mysqli query here");
$sql->bind_param('ssss', $val, $of, $v[$i][0], $v[$i][1]);//error here
$sql->execute();
$i++;
}
return true;
}
}
原因是什么,如何解决?谢谢
i am trying this code, but i get this error:
Only variables can be passed by reference in xxx
script
class page {
function insert($db, $of, $form, &$arr) {
$i = 0;
foreach(array_combine($form['value0'], $arr) as $val=>$v){
$sql->prepare("mysqli query here");
$sql->bind_param('ssss', $val, $of, $v[$i][0], $v[$i][1]);//error here
$sql->execute();
$i++;
}
return true;
}
}
what is the reason, and how can be solved ? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在使用
mysqli::bind_param< /代码>
。除第一个参数之外的所有参数均通过引用传递。这意味着它们必须是变量,而不是字符串、数组元素等。我实际上不确定为什么它需要通过引用来执行此操作,但没关系。你可以很容易地修复它:
I assume you're using
mysqli::bind_param
. All arguments except the first are passed by reference. This means they must be variables, and not strings, array elements, etc. I'm actually not sure why it needs to do this by reference, but never mind. You can fix it pretty easily: