Cannot redeclare function %s() (previously declared in %s:%d)¶
Description¶
Functions must have a unique name: there cannot be two functions with the same name.
Function names are case insensitive, so making changing the case doesn’t make the function name unique.
In fact, two functions in the same namespace cannot have the same name, so the complete constraint is namespace + function must be unique.
Example¶
<?php
function foo() {}
function FOO() {}
?>
Literal Examples¶
Cannot redeclare foo() (previously declared in file:3)
Solutions¶
Change the name of the function.
Make the function a closure.
Move the function to another namespace.
In previous PHP versions, this error message used to be Cannot redeclare %s() (previously declared in %s:%d).