Zen Cart 138 Fatal Error:cannot Redeclare date_diff () in includes/functions/functions_general.php Error resolution in PHP5.3 environment
The reason is that the function already exists in this file: Date_diff (), at this point, we need to be compatible with the old version of PHP, the Zen Cart in the Date_diff () function to modify, the workaround is as follows:
if(function_exists(' Date_diff ') &&phpversion() >= 5.3) {Date_diff (Date_create ($date 1), Date_create ($date 2));}Else{ functionDate_diff ($date 1,$date 2) { //$date 1 today, or any other day//$date 2 date to check against $d 1=Explode("-",$date 1); $y 1=$d 1[0]; $m 1=$d 1[1]; $d 1=$d 1[2]; $d 2=Explode("-",$date 2); $y 2=$d 2[0]; $m 2=$d 2[1]; $d 2=$d 2[2]; $date 1_set=Mktime(0,0,0,$m 1,$d 1,$y 1); $date 2_set=Mktime(0,0,0,$m 2,$d 2,$y 2); return(round(($date 2_set-$date 1_set)/(60*60*24))); }}
Above, we judge the existence of the Date_diff () function, and determine the PHP version number, in addition, we can also see that we use a new version of PHP function: Date_create (), according to the date and time parameters given to return the Unix timestamp, detailed information can be seen: http ://www.php.net/manual/en/function.date-create.php.
In addition, Date_diff () details in PHP5.3 can also be viewed: http://www.php.net/manual/en/function.date-diff.php
Zen Cart 138 Fatal Error:cannot Redeclare Date_diff () appearing in PHP5.3 environment