PHP 5.3.1的按引用传递问题 [英] Pass by reference problem with PHP 5.3.1
问题描述
好的,这是一个奇怪的问题,所以请按我的解释忍受.
Ok, this is a weird problem, so please bear with me as I explain.
我们将开发服务器从PHP 5.2.5升级到了5.3.1.
We upgraded our dev servers from PHP 5.2.5 to 5.3.1.
切换后加载我们的代码,我们开始收到如下错误:
Loading up our code after the switch, we start getting errors like:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /home/spot/trunk/system/core/Database.class.php on line 105
提及的行(105)如下:
the line mentioned (105) is as follows:
call_user_func_array(Array($stmt, 'bind_param'), $passArray);
我们将行更改为以下内容:
we changed the line to the following:
call_user_func_array(Array($stmt, 'bind_param'), &$passArray);
在这一点上(因为allow_call_time_pass_reference
)已关闭,php抛出了这一点:
at this point (because allow_call_time_pass_reference
) is turned off, php throws this:
Deprecated: Call-time pass-by-reference has been deprecated in /home/spot/trunk/system/core/Database.class.php on line 105
尝试修复此问题一段时间后,我崩溃了,将allow_call_time_pass_reference
设置为on.
After trying to fix this for some time, I broke down and set allow_call_time_pass_reference
to on.
这消除了Deprecated
警告,但现在每次有或没有引用时都会抛出Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference
警告.
That got rid of the Deprecated
warning, but now the Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference
warning is throwing every time, with or without the referencing.
我不知道如何解决此问题.如果目标方法是我自己的方法,则只需在func声明中引用传入的var,但这是(相对)本机方法(mysqli).
I have zero clue how to fix this. If the target method was my own, I would just reference the incoming vars in the func declaration, but it's a (relatively) native method (mysqli).
有人经历过吗?我该如何解决?
Has anyone experienced this? How can I get around it?
谢谢.
推荐答案
您正在传递元素数组($ passArray).传递的数组 inside 中的第二项需要作为引用,因为这实际上是您要传递给该函数的项的列表.
You are passing an array of elements ($passArray). The second item inside the passed array needs to be a reference, since that is really the list of items you are passing to the function.
这篇关于PHP 5.3.1的按引用传递问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!