PHP报错"Deprecated: Methods with the same name ...

    选择打赏方式

昨天在帮人修BUG的时候发现提示了个致命报错,我模拟一下案例:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;Pjax has a deprecated constructor in /www/wwwroot/www.recho.cn/include/pjax.class.php on line 5

通过查看PHP官网的文档发现,php7.0之后将不再支持与类名相同的构造方法,构造方法统一使用 __construct()

查找代码:include/pjax.class.php 第5行

<?php
class Pjax
{
    // 构造函数
    function Pjax()
    {
        if (!empty($问题) && !empty($钱))
        {
            $问题 = '解决';
        } else {
            $问题 = '无解';
        }
    }
}

修改成

<?php
class Pjax
{
    // 构造函数
    function __construct()
    {
        if (!empty($问题) && !empty($钱))
        {
            $问题 = '解决';
        } else {
            $问题 = '无解';
        }
    }
}
版权声明:若无特殊注明,本文为《傲世》原创,转载请保留文章出处。
本文链接:https://www.recho.cn/153.html
正文到此结束

热门推荐

发表吐槽

匿名评论 请叫我雷锋~

你还可以输入 250 / 250 个字

呵呵 哈哈 吐舌 开心 笑眼 可怜 乖 啊 你懂得 不高兴 生气 汗 黑线 哭 真棒 阴险 鄙视 酷 滑稽 纳尼 疑问 委屈 惊讶 勉强

评论信息框
可使用QQ号实时获取头像自动填写

私密评论

吃奶的力气提交吐槽中...


竟然没有人吐槽,快赶紧抢沙发吧!