Error Codeigniter php7

I have a site on Codeigniter 2, and when I switch the server version to PHP7, I get the following two errors:

PHP error has occurred. Severity: Notification Message: Only variables should be assigned by reference File name: core / Controller.php Line number: 51

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

PHP error occurred Severity: 8192 Message: methods with the same name as their class will not be constructors in a future version of PHP; CI_DB_driver has an outdated constructor File name: database / DB_driver.php Line number: 31

Does anyone know how to fix them?

+5
source share
2 answers

In the end, I just upgraded the CI kernel to CodeIgniter 2.2.6. I had to replace the DB driver with mysqli (since mysql is no longer supported in php7) and re-added the ci_sessions table to the database (I donโ€™t know why). And it works like a charm!

+10
source

Only variables should be assigned by reference

This error is not an exclusive version of PHP 7, you will also get it in older versions. Anyway, I think the problem here is is_loaded() , and it does not return the link correctly. Does it return by reference (it's like function &is_loaded() )? If not, it is necessary. Does it return a variable or expression? If this is not a variable, you need to put it in one before you can return a link to it.

PHP man page for this error: http://php.net/manual/en/language.references.return.php

Methods with the same name as their class will not be constructors in a future version of PHP; CI_DB_driver has an obsolete constructor

In PHP 4, you created a constructor method, calling it the same as a class. Therefore, if your class was class FooBar , your constructor would be a public function FooBar . However, in PHP 5 and above, the recommended name for the __construct constructor is. So go ahead and edit this class and rename its constructor to get rid of obsolescence errors. Be sure to look at any expandable classes to see if they call this constructor method, so you can change them.

See update guide: http://php.net/manual/en/migration70.deprecated.php

Also see RFC: https://wiki.php.net/rfc/remove_php4_constructors

+2
source

Source: https://habr.com/ru/post/1238010/


All Articles