Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php提示Redefining already defined constructor for class 错误

php提示Redefining already defined constructor for class 错误

发布时间:2017-12-13   编辑:www.jquerycn.cn
jquery中文网为您提供php提示Redefining already defined constructor for class 错误等资源,欢迎您收藏本站,我们将为您提供最新的php提示Redefining already defined constructor for class 错误资源
使用是公司同事以前的电脑了它用的是php2.17了,小编觉得它旧了于时升级到了php5.4了,结果发现运行ecshop中现Redefining already defined constructor for class 错误了,那么这个问题如何处理?我们一起来看看吧。

本地PHP环境PHP5.4,安装ecshop2.7.3后,很多地方会报如下的错

Redefining already defined constructor for class XXX

检查代码可以发现,对应的位置是某个类的构造函数,具体写法如下:


/**
     * 构造函数
     *
     * @access  public
     * @param
     *
     * @return void
     */
    function alipay()
    {
    }

    function __construct()
    {
        $this->alipay();
    }

其中使用和类名相同点函数名作为构造函数是php4时代的写法,php5时代的构造函数是 __construct(),ecshop为了兼容老版本的php,所以采用了上面的写法。

但是从php5.4开始,对于这样的两种写法同时出现的情况,要求必须__construct()在前,同名函数在后,所以只需要对调两个函数的位置即可。

您可能感兴趣的文章:
php提示Redefining already defined constructor for class 错误
解决PHP5.4环境下ECSHOP网站报错的方法
PHP构造函数的深入理解
常见的几个问题
php error_reporting()函数的用法举例(错误捕捉)
session Cannot send session cache limiter 错误提示
提示$ is not defined错误分析及解决
php实现上传图片功能
Warning: session_start() [function.session-start]
hp函数setcookie()报错:Warning: Cannot modify header

[关闭]