[PHP] Deprecated

问题:Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; exchange has a deprecated constructor in E:\hz1884\ChinaShop\admin\includes\cls_exchange.php on line 3

php版本由5.6升级到7.2,运行ecshop,报以上错误
原因是
PHP OOP使用和类名相同的方法名作为构造方法,是 PHP4 的写法,PHP 5中同时支持__construct和类同名方法,但__construct方法具有优先性。
PHP 7开始使用和类名相同的方法名作为构造方法会报E_DEPRECATED级别的错误,提示在未来版本中会彻底抛弃类同名方法作为

构造函数。
但程序仍然会正常执行。

猜你喜欢

转载自blog.csdn.net/weixin_42809940/article/details/84339931