ECSHOP错误Redefining already defined constructor for class如何解决

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

Redefining already defined constructor for class XXX

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

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

 

解决方案:打开ecshop目录下includes/cls_captcha.php,并执行下面操作。

把代码1 放到代码2后面就解决错误了

代码1:

 1 /**
 2     * 构造函数
 3     *
 4     * @access  public
 5     * @param   string  $folder     背景图片所在目录
 6     * @param   integer $width      图片宽度
 7     * @param   integer $height     图片高度
 8     * @return  bool
 9     */
10    function captcha($folder = '', $width = 145, $height = 20)
11    {
12        if (!empty($folder))
13        {
14            $this->folder = $folder;
15        }
16  
17        $this->width    = $width;
18        $this->height   = $height;
19  
20        /* 检查是否支持 GD */
21        if (PHP_VERSION >= '4.3')
22        {
23  
24            return (function_exists('imagecreatetruecolor') || function_exists('imagecreate'));
25        }
26        else
27        {
28  
29            return (((imagetypes() & IMG_GIF) > 0) || ((imagetypes() & IMG_JPG)) > 0 );
30        }
31    }
View Code

代码2:

 1 /**
 2  * 构造函数
 3  *
 4  * @access  public
 5  * @param
 6  *
 7  * @return void
 8  */
 9 function __construct($folder = '', $width = 145, $height = 20)
10 {
11     $this->captcha($folder, $width, $height);
12 }
View Code

 

posted on 2014-07-01 15:29  跌名  阅读(3231)  评论(0编辑  收藏  举报

导航