The Codeigniter framework has a great legacy, so it uses some techniques that have fallen into disuse. The problem in this case is the &
in the signature of the get_config()
method, which forces the return to be a reference (variable).
If you can measure the impact of the change, another solution is to remove the &
of the signature. Since this code snippet is part of ( Comum
/ Common
;)) of the framework, it can lead to unexpected behavior.
Signature:
function &get_config($replace = array())
Change:
return $_config[0] =& $config;
To: as corrected in the version 2.2.x
$_config[0] =& $config;
return $_config[0];
A simple way to reproduce the error is with the following code:
function &olaMundo(){
return 'Ola mundo';
}
echo olaMundo(); //Notice: Only variable references should be returned by reference in
Correction:
function &olaMundo(){
$x = 'Ola mundo';
return $x;
}
Functional example run in various php versions.