PHP CodeIgniter common.php出错

I am using CodeIgniter and I have a problem the code very simple just few row in the controller ,this is my controller

<?php
class Site extends Controller {

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

}

And this are the errors:

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

I don't know where is the problem, certainly the code is correct but where is the problem. Any suggestions?

2个回答

& is used in PHP to pass an object to a method / assign a new object to a variable by reference. It is deprecated in PHP 5 because PHP5 passes all objects by reference, but other vars default to by value.

To fix this error:

Update to the latest version of CodeIgniter, really!

doure8758
doure8758 手动删除所有&可能工作,但不保证。 你为什么不想更新? :)
7 年多之前 回复
douzhi1879
douzhi1879 我可以修改它而不更新?
7 年多之前 回复

Recently I faced the same prob, I was using codeigniter 1.7 and PHP 5.2.6 everything was working great, but after upgrading PHP to 5.3 the below error starts coming:-

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

The reason behind it is same as mentioned by @Amal , & is used in PHP to pass an object to a method / assign a new object to a variable by reference. It is deprecated in PHP 5 because PHP5 passes all objects by reference

For more info Refer to

Assigning the return value of new by reference is deprecated

So if you are creating your code from scratch, then better to use all the latest things, use codeigniter 2.1.4

But if you have your codebase in some old codeigniter version, then better to degrade your PHP (which is not recommended) till the time you move on to newer version.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐