In codeIgniter I auto load the url_helper.php
In my site I also have a phpbb forum and so within codeigniter im trying to include
a script from the forum.
The problem is, phpbb tries to declare a function redirect()
but its already declared in the url_helper.php so i get the following error
Cannot redeclare redirect() (previously declared in C:\Apache24\htdocs\system\helpers\url_helper.php:531) in C:\Apache24\htdocs\forum\includes\functions.php on line 2562
What can I do go go around this? Can I unset the function or remove the url_helper entirly in my controller function?
Ok, I got a work around. In the codeigniter's helper library, before declaring a function, it first checks if it has been declared before or not. So....
In my controller class's constructor method, I load all the phpbb files I need. this way it declares the phpbb redirection function and codeigniter goes "ohh there is already a redirect function" and so it doesn't declare the redirect function... Problem solved
Something like this:
class Register extends CI_Controller{
public function __construct()
{
/* START phpbb */
.
.
.
require_once('forum/common.php');
require_once('forum/includes/functions_user.php');
require_once('forum/includes/functions_module.php');
/* END phpbb */
//Continue as normal
parent::__construct();
}
public function index(){
//Your stuff works as normal now
}
}
Still a bit of a hack, but see: http://php.net/manual/en/function.rename-function.php
You could create your own url_helper, include the CI url_helper, and call after include:
rename_function('redirect', 'ci_redirect');