Only Variable References Should Be Returned by Reference - Codeigniter

Only variable references should be returned by reference - Codeigniter

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

Before

return $_config[0] =& $config; 

After

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

Update

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

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.

CodeIgniter Error: variable references

Try this one:

Change it in your Common.php

if (count($replace) > 0){
foreach ($replace as $key => $val){
if (isset($config[$key])){
$config[$key] = $val;
}
}
}

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

See also here , for more reference : Only variable references should be returned by reference - Codeigniter . I hope this helps.

Only variable references should be returned by reference - Codeigniter

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

Before

return $_config[0] =& $config; 

After

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

Update

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

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.

How to fix Notice: Only variable references should be returned by reference in

Based on the notice you get and on an answer to another related question:

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

Changing your code from:

return new BEncode_End();

To:

$cl = new BEncode_End();
return $cl;

Should solve your problem.

Only variables should be assigned by reference with function

Please see this url

https://github.com/bcit-ci/CodeIgniter/issues/904

You can go to file: system/core/Loader.php
Then
file: system/core/Common.php Line 190 there should be:

function &is_loaded($class = '')

changes core/Common.php results net::ERR_TOO_MANY_REDIRECTS

in core/Common.php

add this line on line no 257

return $_config[0];  

i have try it its working for me when i upgraded my codeigniter version



Related Topics



Leave a reply



Submit