dongwaner1367 2013-09-27 02:58
浏览 42
已采纳

codeIgniter中的函数帮助与另一个函数冲突

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?

  • 写回答

2条回答 默认 最新

  • dongyuxin5353 2013-09-27 03:30
    关注

    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
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题