dpk20361
2013-07-19 01:47
浏览 71

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条回答 默认 最新

  • doupuxuan5784 2013-07-19 01:49

    & 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!

    评论
    解决 无用
    打赏 举报
  • dongyang4615 2013-07-19 03:12

    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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题