dedecms报错“Deprecated: Methods with the same name as their class will not be”的解决方法

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Model has a deprecated constructor in /data/web/mdz-guanwang/include/model.class.php on line 12

查阅资料,发现php7.0之后将不再支持与类名相同的构造方法,构造方法统一使用 __construct()。

查找代码:include/model.class.php 第12行


class Model
{
    var $dsql;
    var $db;


    // 析构函数
    function Model()
    {
        global $dsql;
        if ($GLOBALS['cfg_mysql_type'] == 'mysqli')
        {
            $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSqli(FALSE);
        } else {
            $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSql(FALSE);
        }
            
    }

修改成


class Model
{
    var $dsql;
    var $db;


    // 析构函数
    function __construct()
    {
        global $dsql;
        if ($GLOBALS['cfg_mysql_type'] == 'mysqli')
        {
            $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSqli(FALSE);
        } else {
            $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSql(FALSE);
        }
            
    }

你可能感兴趣的:(Php,Dedecms织梦)