php 只应通过引用返回变量引用 - Codeigniter
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28348879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Only variable references should be returned by reference - Codeigniter
提问by Techie
After the server PHP upgrade I am getting the following error with PHP Version 5.6.2 on Apache 2.0
服务器 PHP 升级后,我在 Apache 2.0 上的 PHP 版本 5.6.2 出现以下错误
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?
我怎样才能解决这个问题?
回答by Techie
Edit filename: core/Common.php, line number: 257
编辑文件名:core/Common.php,行号:257
Before
前
return $_config[0] =& $config;
After
后
$_config[0] =& $config;
return $_config[0];
Update
更新
Added by NikiC
由 NikiC 添加
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).
在 PHP 赋值表达式中总是返回赋值的值。所以 $_config[0] =& $config 返回 $config - 但不是变量本身,而是它的值的副本。并返回对临时值的引用不会特别有用(更改它不会做任何事情)。
Update
更新
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.
此修复程序已合并到 CI 2.2.1 ( https://github.com/bcit-ci/CodeIgniter/commit/69b02d0f0bc46e914bed1604cfbd9bf74286b2e3)。最好升级而不是修改核心框架文件。
回答by Chad
this has been modified in codeigniter 2.2.1...usually not best practice to modify core files, I would always check for updates and 2.2.1 came out in Jan 2015
这已在 codeigniter 2.2.1 中进行了修改……通常不是修改核心文件的最佳实践,我总是会检查更新,2.2.1 于 2015 年 1 月发布
回答by Maniruzzaman Akash
It's not a better idea to override the core.common file of codeigniter. Because that's the more tested and system files....
覆盖 codeigniter 的 core.common 文件并不是一个更好的主意。因为那是更多测试和系统文件....
I make a solution for this problem. In your ckeditor_helper.php file line- 65
我为这个问题制定了一个解决方案。在您的 ckeditor_helper.php 文件中,第 65 行
if($k !== end (array_keys($data['config']))) {
$return .= ",";
}
Change this to-->
将此更改为-->
$segment = array_keys($data['config']);
if($k !== end($segment)) {
$return .= ",";
}
I think this is the best solution and then your problem notice will dissappear.
我认为这是最好的解决方案,然后您的问题通知就会消失。