問題描述
好吧,這是一個奇怪的問題,所以請耐心聽我解釋.
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:
警告:mysqli_stmt::bind_param() 的參數 2 應為參考,值在/home/spot/trunk/system/core/Database.class.php 第 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:
已棄用:/home/spot/trunk/system/core/Database.class.php 中的第 105 行已棄用調用時傳遞引用
在嘗試解決此問題一段時間后,我崩潰了并將 allow_call_time_pass_reference
設置為開啟.
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() 預計將成為參考
警告每次都拋出,有或沒有引用.
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 聲明中引用傳入的變量,但它是一個(相對)本機方法 (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).傳遞的數組內的第二個項目需要是一個引用,因為那確實是您傳遞給函數的項目列表.
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 傳遞引用問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!