PHP出现Methods with the same name as their class will not be constructors in a future version of PHP;


PHP版本在升级到高版本的时候往往会出现某些函数或语法被屏弃的现象,笔者环境从PHP 5.5 升级到PHP 7.0的时候原来的站点访问的时候就出现了如下错误:

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

从上面英文错误的字面上理解是在定义类的时候使用了与类名相同的函数名称,在PHP5里运行实际是没有报错的,但在PHP 7里就不允许这样写,解决办法很简单,只要把与类名相同的函数名改为“__construct”,也就是我们熟知的构造函数咯。

注:本文转载自唯马网络,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除。

评论


匿名用户:
2023-07-22 15:26:56

345345345345


匿名用户:
2023-06-19 14:51:27

111111111111111111


匿名用户:
2022-11-12 20:17:43

 Methods with the same name as their class will not be constructors in a future version of PHP; Services_JSON has a deprecated constructor in D:\wwwroot\aixinan.cn\include\kindeditor\JSON.php on line 58