发布时间:2020-03-11 08:16:44 作者:佚名 阅读:(666)
今天把服务器上面的PHP版本从5.6.3升级到php7.1.3,打开网站时却提示Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP,接下来吾爱编程为大家介绍一下解决方法,有需要的小伙伴可以参考一下:
由于PHP7开始P不再支持与类名相同的构造方法,构造方法统一使用 __construct(),导致网站在PHP5.6版本下开发的网站不能正常运行。
<?php /**验证码*/ class Captcha { var $captcha_width = 70; var $captcha_height = 25; /** * +---------------------------------------------------------- * 构造函数 * +---------------------------------------------------------- */ function Captcha($captcha_width, $captcha_height) { $this->captcha_width = isset($captcha_width) && $captcha_width > 0 ? $captcha_width : $this->captcha_width; $this->captcha_height = isset($captcha_height) && $captcha_height > 0 ? $captcha_height : $this->captcha_height; } }
更改为:
<?php /**验证码*/ class Captcha { var $captcha_width = 70; var $captcha_height = 25; /** * +---------------------------------------------------------- * 构造函数 * +---------------------------------------------------------- */ function __construct($captcha_width, $captcha_height) { $this->captcha_width = isset($captcha_width) && $captcha_width > 0 ? $captcha_width : $this->captcha_width; $this->captcha_height = isset($captcha_height) && $captcha_height > 0 ? $captcha_height : $this->captcha_height; } }
以上就是吾爱编程为大家介绍的关于Deprecated: Methods with the same name as their class will not be constructors错误的解决方法,了解更多相关文章请关注吾爱编程网!
欢迎分享转载→ Deprecated: Methods with the same name as their class will not be constructors
彻底理解PHP的SESSION机制
发布时间:2021-01-08php session封装类
发布时间:2021-01-08php实现精确设置session过期时间的方法
发布时间:2021-01-07php开启与关闭错误提示
发布时间:2021-01-04php过滤不可见0长度的字符u200b
发布时间:2021-01-03php将字符串转为ASCII,php将中文汉字字符串转为ASCII
发布时间:2020-12-27PHP开源ERP和CRM系统
发布时间:2020-12-24Warning:file_get_contents():SSL operation failed with code 1
发布时间:2020-12-23php中ipv6转纯数字和反转
发布时间:2020-12-17Discuz论坛禁止匿名发贴,却出现匿名发帖或回复?找不到发帖用户,DZ如何禁止匿名发帖修改教程
发布时间:2020-12-07© 2015-2021 - 吾爱编程网 版权所有 苏ICP备18033726号-1关于我们 - 网站声明 - 联系我们