I have an existing PHP application that I am trying to translate pbpBB into. phpBB has functions that have the same name as some of my existing functions. This causes the following error:
E_COMPILE_ERROR Error in file »functions.php« at line 121: Cannot redeclare redirect() (previously declared in /.../httpdocs/forum/includes/functions.php:2289)
I could rename the functions in the phpBB application, but this may cause problems with future updates. In my code, I would have to rename 512 function instances. Namespaces will require the same effort.
Is there a way to indicate that a particular function should only be used when called from a specific directory? For example, I would define redirect () as a function that will be used when calling from httpdocs / forum and another function with the same name elsewhere in the code that will be used when calling from / httpdocs / myapp. This seems to be practical, but I could not find such a solution.
source
share