Reputation: 187
I have an existing PHP application into which I am trying to intergate pbpBB. phpBB has functions that have the same name as some of my existing functions. This generates 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 that could cause problems with future updates. In my code I would have to rename 512 instances of the function. Namespaces would require the same effort.
Is there a way to specify that a particular function should be used only when called from a specific directory? For example, I would define redirect() as a function to be used if called from httpdocs/forum and another function with the same name elsewhere in the code to be used when called from /httpdocs/myapp. Seems like it is practical but I could not find such a solution.
Upvotes: 4
Views: 119
Reputation: 9
This is precisely what namespacing is for, but phpBB is old and crufty and doesn't use namespacing, so I'm guessing that's not an option for you. Your best bet is either to rename the conflicting functions in your app, or just keep them separate and simply display your phpBB forum in an iframe and call it day. If your existing php app has sessions you need to integrate, hopefully you're keeping your sessions in a DB and you can write a connector to pass session data between the two apps without much trouble. Otherwise, you're in for a bad day.
Upvotes: 1