2

I used cakephp with version 1.1.7692.

When i run it with php ver > 5.3.2, it has bug :

Fatal error: Cannot redeclare date_diff().

and i run it with php ver 5.2.9, it display very text and code same as :

quality = 100; $thumb->fileName = "/path/to/file.jpg"; //IMPORTANT -
must run init() function before any manipulation is performed
$thumb->init(); //shrink image by 50% $thumb->percent = 50;
$thumb->resize(); //crop image to 350x350 from center of image
$thumb->cropSize = 350; $thumb->crop(); //resize image to no more than
125px wide $thumb->percent = 0; $thumb->maxWidth = 125;
$thumb->resize(); //save image as 'filename.jpg'
$thumb->save('/path/to/save/filename.jpg'); You can also use this
class to dynamically generate thumbnails and display them After you
have made your manipulations you could display the result by: echo '';
*/ class ThumbnailComponent extends Object { var $errmsg;    //error message to parse var $error;    //flag for whether there is an error var
$format;     //file format of image var $currentDimensions=array(); 
//current dimensions of working image var $newDimensions=array();   
//new dimensions after manipulation var $newImage;   //final image to
be displayed/saved var $oldImage;    //original image to be manipulated
var $workingImage;   //working image being manipulated var $fileName;   
//filename of image, can include directory var $maxWidth;    //maximum
width of the image var $maxHeight;   //maximum height of the image var
$percent;    //percentage of the original image size var $quality;  
//image quality of jpeg images var $cropSize;....

This is function date_diff :

function date_diff($start_date,$end_date)
    {
        $splitstdate = split(" ",$start_date); 
        $splitenddate = split(" ",$end_date); 

        list($year,$month,$day)=split("-",$splitstdate[0]);
        list($year_test,$month_test,$day_test)=split("-",$splitenddate[0]);


        list($hour,$min,$sec)=split(":",$splitstdate[1]);
        list($hour_test,$min_test,$sec_test)=split(":",$splitenddate[1]);

        $start = mktime($hour, $min, $sec,$month,$day,$year);
        $end = mktime($hour_test, $min_test,$sec_test,$month_test,$day_test,$year_test);
        $date_diff =   $start-$end;
        if($date_diff<0)
        $date_diff=0;
        $days = intval($date_diff /(3600*24)) ; 

        $hms = date('h \h\r \m\i\n s \s\e\c \a\g\o',$date_diff);
        return $days.' days '.$hms ;
}

Who can know the cause of bug and method resolve it? Thanks all.

Baba
  • 94,024
  • 28
  • 166
  • 217
Hyeongsik
  • 125
  • 1
  • 3
  • 7

2 Answers2

3

date_diff is inbuilt function in php version 5.3.0 you can't redeclare it.

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
3

date_diff() is inbuilt function of php version 5.3.0. and above version, you can check http://php.net/manual/en/function.date-diff.php that's why you get Fatal error: Cannot re-declare date_diff() so change your function name this will solve your problem

you can check my answer https://stackoverflow.com/a/14938421/718224 on date difference for more information.

NOTE: In versions < 5.3.0 I simply use this form for calculate the number of days

<?php
$today = strtotime("2011-02-03 00:00:00");
$myBirthDate = strtotime("1964-10-30 00:00:00");
printf("I'm %d days old.", round(abs($today-$myBirthDate)/60/60/24));
?>
Community
  • 1
  • 1
Tony Stark
  • 8,064
  • 8
  • 44
  • 63