找回密码
 注册会员

QQ登录

只需一步,快速开始

查看: 916|回复: 0

[转载] 209 报错“Deprecated: Methods with the same name as their class will not be”...

[复制链接]
发表于 2022-4-27 09:30:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转南昌530论坛

您需要 登录 才可以下载或查看,没有账号?注册会员

×
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Model has a deprecated constructor


发现php7.0之后将不再支持与类名相同的构造方法,构造方法统一使用 __construct()。
  1. class Model
  2. {
  3.     var $dsql;
  4.     var $db;


  5.     // 析构函数
  6.     function Model()
  7.     {
  8.         global $dsql;
  9.         if ($GLOBALS['cfg_mysql_type'] == 'mysqli')
  10.         {
  11.             $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSqli(FALSE);
  12.         } else {
  13.             $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSql(FALSE);
  14.         }
  15.             
  16.     }
复制代码

改成这样就行了
  1. class Model
  2. {
  3.     var $dsql;
  4.     var $db;


  5.     // 析构函数
  6.     function __construct()
  7.     {
  8.         global $dsql;
  9.         if ($GLOBALS['cfg_mysql_type'] == 'mysqli')
  10.         {
  11.             $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSqli(FALSE);
  12.         } else {
  13.             $this->dsql = $this->db = isset($dsql)? $dsql : new DedeSql(FALSE);
  14.         }
  15.             
  16.     }
复制代码

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

如需要(删违规/投诉/建议/赞助等)请联系

本论坛所有来帖仅代表网友个人观点,不代表青山湖畔|南昌论坛立场。

手机版|南昌530论坛

GMT+8, 2026-2-25 20:28

Powered by Discuz! X3.5

Cpoyright © 2001-2026 Discuz! Team

快速回复 返回顶部 返回列表