2013-07-19 63 views
0

我使用笨,我有一個問題 代碼非常簡單隻有幾行中的控制器,這是我的控制器錯誤用PHP笨的common.php

<?php 
class Site extends Controller { 

    function index() { 
     echo 'i am here'; 
    } 

} 

這是錯誤的:

1- Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\ci\system\codeigniter\Common.php on line 130 
2-Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\ci\system\codeigniter\Common.php on line 136 
3-A PHP Error was encountered 

Severity: 8192 
Message: Assigning the return value of new by reference is deprecated 
Filename: libraries/Loader.php 
Line Number: 255 
4-A PHP Error was encountered 
Severity: 8192 
Message: Assigning the return value of new by reference is deprecated 
Filename: database/DB.php 
Line Number: 133 

我不知道問題在哪裏,當然代碼是正確的,但問題在哪裏。有什麼建議麼?

回答

0

&在PHP中用於將對象傳遞給方法/通過引用將新對象分配給變量。它在PHP 5中被棄用,因爲PHP5通過引用傳遞所有對象,但其他變量默認爲值。

要修正這個錯誤:

更新到CodeIgniter的最新版本,真的!

+0

我可以修改它而不更新? – user2026521

+0

手動刪除所有'&* *可能*工作,但不能保證。你爲什麼不想更新? :) –

0

最近我面臨着相同的概率,我是用笨1.7和PHP 5.2.6一切是偉大的工作,但升級到PHP 5.3後下面的錯誤啓動未來 -

Deprecated: Assigning the return value of new by reference is deprecated 

背後的原因它與@Amal提到的相同,在PHP中使用&將對象傳遞給方法/通過引用將新對象分配給變量。因爲PHP5經過引用的所有對象

欲瞭解更多信息,請參閱

Assigning the return value of new by reference is deprecated

所以,如果你是從頭開始創建你的代碼,它在PHP 5過時,那麼最好使用所有最新的東西,使用codeigniter 2.1.4

但是,如果你有一些舊的codeigniter版本的代碼庫,那麼最好是降級你的PHP(這是不推薦的),直到你轉向更新的版本。