Only variables should be assigned by reference with function
Asked Answered
W

5

12

I use old version of Codeigniter framework. With new version of php I am gettings this error: Only variables should be assigned by reference

I am wondering if this is safe bugfix: Changing:

 $this->_base_classes =& is_loaded();

to

$assign = is_loaded();    
$this->_base_classes =& $assign;

Is that the same?

Wendellwendi answered 22/1, 2017 at 10:10 Comment(0)
L
22

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 = '')
Luzern answered 24/1, 2017 at 5:30 Comment(0)
L
3

This is an codeigniter bug in which the old version does not support anymore the mysql.

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

//function is_loaded($class = '') >>> Edit this one like the expression below

  function &is_loaded($class = '')

function &is_loaded($class = '')

After that go to file: application/config/database.php and change the following below:

//$db['default']['dbdriver'] = 'mysql'; >>> Edit this one like the expression below.

$db['default']['dbdriver'] = 'mysqli';

I hope it works

Lethalethal answered 14/4, 2018 at 8:21 Comment(1)
You should edit your post to include code formatting. Also, does this change the actual SQL driver to a different database driver?Eagan
P
1

remove this in line 150 from system/core/Loader.php

$this->_base_classes =& is_loaded(); ..

Parturifacient answered 22/8, 2017 at 8:44 Comment(0)
F
1

Go to File: system\core you will find a file named as Common.php open the file and go to line 190 where you will find function is_loaded($class = '') just replace it by this line of code function &is_loaded($class = '')

Filberte answered 22/7, 2020 at 12:33 Comment(3)
Not a good idea to change the file directly in the core. The proper way is to copy that file into application/core/MY_Common.php and change it there leaving the original one intact.Gaia
Why do you feel its not a good idea?? I have tried it myself it didn't give any issue for me.Filberte
Because if you ever need to upgrade that version of codeigniter to a newer one having the system files modified will give you an extra headache.Gaia
C
0

Change

$this->_base_classes =& is_loaded();

to

$this->_base_classes = $this->is_loaded();

Worked for me.

Caldron answered 13/7, 2018 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.