[php] Only variable references should be returned by reference - Codeigniter

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?

This question is related to php apache codeigniter apache2 codeigniter-2

The answer is

Edit filename: core/Common.php, line number: 257


return $_config[0] =& $config; 


$_config[0] =& $config;
return $_config[0]; 


Added by 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).


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.

Similar questions with php tag:

Similar questions with apache tag:

Similar questions with codeigniter tag:

Similar questions with apache2 tag:

Similar questions with codeigniter-2 tag: