2013-12-13 69 views
-1

第一誤差是升級服務器從5.2 PHP來5.4,具有錯誤現在

Strict Standards: Only variables should be passed by reference in /home/.sites/143/site2/dispatch.php on line 196

dispatch.php的線196看起來像這樣

$table_name = array_pop(split('/',$controller)); 

第二誤差是

Strict Standards: Only variables should be passed by reference in /home/.sites/143/site2/lib/referer.php on line 18

referer.php的行18看起來像這樣

$agentInfo = array_pop($db->get('agencies','company_name,enabled',"id='$agent_id'")); 

第三誤差

Strict Standards: Only variables should be passed by reference in /home/.sites/143/site2/controllers/step4.php on line 978

step4.php的行978看起來像這樣

$info = array_pop($this->db->get_records_by_sql($sql)); 
+3

把這些成兩行代碼在'array_pop()的代碼'爲自己的路線。 –

+1

約翰,那應該是答案。 – Jessica

+0

http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference – Cole

回答

0

嘗試改變第一個

$r=explode('/',$controller); 
$table_name = array_pop($r); 

然後

​​

$q=$this->db->get_records_by_sql($sql); 
$info = array_pop($q); 

這是因爲array_pop返回變量的參考值的功能,最後陣列會員。注意這只是嚴格的警告,而不是錯誤。

+0

謝謝科爾,你的修復工作,並告訴我爲什麼它不能正常工作! – CanadianCaveman

2

在你的代碼,你的split()函數的返回值傳遞給array_pop(),但array_pop()需要一個數組通過引用傳遞,而不是一個值。

可以通過在文檔中的功能描述尋找array_pop()驗證:

mixed array_pop (array & $array)

&號表示函數希望通過引用傳遞的陣列。

您可以通過使用數組變量來存儲函數的輸出來解決此問題。另請注意,split()已棄用。改爲使用explode()

$array = explode('/', $controller); 
$table_name = array_pop($array); 

更改所有相似的發生。

+0

嘗試生成錯誤 解析錯誤:語法錯誤,意外的'$ table_name '(T_VARIABLE)in /home/.sites/143/site2/dispatch.php on line 134 我也試過了preg_split,它也會產生不同的錯誤:[ – CanadianCaveman

+0

@CanadianCaveman:什麼錯誤?我是否真的改變了代碼? –

+0

解析錯誤:語法錯誤,第134行的/home/.sites/143/site2/dispatch.php中的意外的'$ table_name'(T_VARIABLE)是我得到的錯誤。 – CanadianCaveman

0

最好是,你應該留在版本5.2中的項目,將來只需使用5.4。你會發現這個錯誤,但你可以在將來發現任何其他錯誤,這不是一種好的方法來消除項目中的所有錯誤。

0

該錯誤意味着PHP函數array_pop()需要對變量的引用而不是值。查看此頁面上$ array參數旁邊的小&?

http://www.php.net/manual/es/function.array-pop.php

您可以修復,通過使用這樣的事情:

$data = $this->db->get_records_by_sql($sql); 
$info = array_pop($data);