PHP Fatal error: Cannot redeclare function

PHP Fatal error: Cannot redeclare function

Posted by Luke Beeno on July 28, 2022

PHP Fatal error: Cannot redeclare function

PHP Fatal error: Cannot redeclare function

Posted by Luke Beeno on July 28, 2022

In order to attempt to solve error "PHP Fatal error: Cannot redeclare", here are a few things to consider:

  • You may have the function declared in seperate files.
  • You may have the function declared twice in the same file
  • The file with the function might have been included twice

               use include_once or require_once when including your file

  • The function might have already been a PHP built in function

              For intance, the function checkDate() is already a PHP function.

              Therefore don't do this:

function checkDate(){
    $currentDay = date('Y-m-d');
    
    return $currentDay;
}

echo checkDate();