只应通过引用返回变量引用 - Codeigniter [英] Only variable references should be returned by reference - Codeigniter
问题描述
服务器 PHP 升级后,我在 Apache 2.0 上的 PHP 版本 5.6.2 出现以下错误
After the server PHP upgrade I am getting the following error with PHP Version 5.6.2 on Apache 2.0
A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257
我该如何解决这个问题?
How can I fix this?
推荐答案
编辑文件名:core/Common.php,行号:257
Edit filename: core/Common.php, line number: 257
之前
return $_config[0] =& $config;
之后
$_config[0] =& $config;
return $_config[0];
更新
由 NikiC 添加
Update
Added by NikiC
在 PHP 赋值表达式中总是返回赋值的值.所以 $_config[0] =&$config 返回 $config - 但不是变量本身,而是其值的副本.返回对临时值的引用不会特别有用(更改它不会做任何事情).
In PHP assignment expressions always return the assigned value. So $_config[0] =& $config returns $config - but not the variable itself, but a copy of its value. And returning a reference to a temporary value wouldn't be particularly useful (changing it wouldn't do anything).
此修复已合并到 CI 2.2.1 (https://github.com/bcit-ci/CodeIgniter/commit/69b02d0f0bc46e914bed1604cfbd9bf74286b2e3).最好升级而不是修改核心框架文件.
This fix has been merged into CI 2.2.1 (https://github.com/bcit-ci/CodeIgniter/commit/69b02d0f0bc46e914bed1604cfbd9bf74286b2e3). It's better to upgrade rather than modifying core framework files.
这篇关于只应通过引用返回变量引用 - Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!