Zen Cart 138 在PHP5.3環境下出現的Fatal error: Cannot redeclare date_diff()

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   使用   ar   檔案   

Zen Cart 138 在PHP5.3環境下出現的Fatal error: Cannot redeclare date_diff() in includes/functions/functions_general.php錯誤的解決方案

原因是在這個檔案中已存在函數:date_diff()了,此時,我們需要做到與舊版本的PHP相容,將Zen Cart中的date_diff()函數進行修改,解決方案如下:

if(function_exists(‘date_diff‘) && phpversion() >= 5.3){    date_diff(date_create($date1), date_create($date2));}else{    function date_diff($date1, $date2) {        //$date1 today, or any other day        //$date2 date to check against                $d1 = explode("-", $date1);        $y1 = $d1[0];        $m1 = $d1[1];        $d1 = $d1[2];                $d2 = explode("-", $date2);        $y2 = $d2[0];        $m2 = $d2[1];        $d2 = $d2[2];                $date1_set = mktime(0,0,0, $m1, $d1, $y1);        $date2_set = mktime(0,0,0, $m2, $d2, $y2);                return(round(($date2_set-$date1_set)/(60*60*24)));    }}

在上面,我們對date_diff()函數是否存在進行判斷,並判斷PHP版本號碼,另外,也可以看到我們使用了PHP新版本的函 數:date_create(),根據給出的日期時間參數返回 Unix 時間戳記,詳細資料可以參看:http://www.php.net/manual/en/function.date-create.php。
另外,PHP5.3中的date_diff()詳細情況也可以查看:http://www.php.net/manual/en/function.date-diff.php

Zen Cart 138 在PHP5.3環境下出現的Fatal error: Cannot redeclare date_diff()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.