“Fatal error: Cannot redeclare

前端 未结 17 1174
[愿得一人]
[愿得一人] 2020-11-22 05:26

I have a function(this is exactly how it appears, from the top of my file):



        
17条回答
  •  天命终不由人
    2020-11-22 06:07

    Another possible reason for getting that error is that your function has the same name as another PHP built-in function. For example,

    function checkdate($date){
       $now=strtotime(date('Y-m-d H:i:s'));
       $tenYearsAgo=strtotime("-10 years", $now);
       $dateToCheck=strtotime($date);
       return ($tenYearsAgo > $dateToCheck) ? false : true;
    }
    echo checkdate('2016-05-12');
    

    where the checkdate function already exists in PHP.

提交回复
热议问题