1

在codeIgniter 中,我自动加载了url_helper.php
在我的站点中,我还有一个phpbb 论坛,因此在codeigniter 中我试图include从论坛中获取脚本。

问题是,phpbb 尝试声明一个函数redirect(),但它已经在 url_helper.php 中声明,所以我收到以下错误

无法在第 2562 行的 C:\Apache24\htdocs\forum\includes\functions.php 中重新声明 redirect()(之前在 C:\Apache24\htdocs\system\helpers\url_helper.php:531 中声明)

我能做些什么来解决这个问题?我可以在我的控制器功能中取消设置功能或完全删除 url_helper 吗?

4

2 回答 2

1

仍然有点破解,但请参阅: http: //php.net/manual/en/function.rename-function.php

您可以创建自己的 url_helper,包含 CI url_helper,并在包含后调用:

重命名函数('重定向','ci_redirect');

于 2013-09-27T03:17:56.987 回答
0

好的,我有一个工作。在 codeigniter 的 helper 库中,在声明一个函数之前,它首先检查它之前是否已经声明过。所以....

在我的控制器类的构造方法中,我加载了我需要的所有 phpbb 文件。这样它就声明了 phpbb 重定向函数并且 codeigniter 去“哦,已经有一个重定向函数”,所以它没有声明重定向函数......问题解决了

像这样的东西:

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
    }
}
于 2013-09-27T03:30:49.480 回答