In case you ever encounter this exact or similar error "PHP Fatal error: Cannot redeclare function", it means that your script is trying to declare the same function multiple times.

This means one of the following things:

  • The function is defined in two separate files

  • The function is defined in two places in the same file

For these two cases, check the full error message: it will tell you in which file this function was previously declared.

  • The file in which you defined your function is included two times

This point can be fixed easily by using include_once instead of include when including your PHP file.

Did this answer your question?