Severity: 8192 Message: Methods with the same name as their class will not be constructors in a future version of PHP;

老子叫甜甜 提交于 2019-12-01 18:40:36

Previously we used to declare class constructor using the class name itself

Class A
{

public function a(){
}
}

Now you need to change a() to construct, like this

public function __construct(){
}

And the error will disappear.

rakesh vadhel

It is occur with new version of php ,So if you want to remove this error please use _construct() instead of same class name function.

So here you have to user

class CI_Pagination {
 public function  __construct() {
 }
}

instead of

class CI_Pagination {
 public function CI_Pagination () {
 }
}
class NewClass{
}
function __construct(){
} //is used inplace of a function named NewClass for constructor

change function name having same name as class to __construct and it will work. Faced such problem in google maps api v3

For Codeigniter

First Step:

class MyClass{
 function __construct(){
    // copy your old constructor function code here
 }
}

Next Step(if first step not working): Open application\config\autoload.php and edit

$autoload['libraries'] = array('database', 'session','browser');

to

$autoload['libraries'] = array('database', 'session');

remove 'browser'

madan chunchu

Loader.php 414 line, I have removed Ampersent.

$CI->dbutil =& new $class();

to

$CI->dbutil = new $class();

It works fine in php5.x.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!