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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM