帮助程序没有加载Codeigniter?

时间:2015-03-17 20:55:52

标签: php codeigniter helper

这是我的简单控制器:

public function _construct()
{
    parent::_construct();
    $this->load->helper('url');
}


public function view($page = "index")
{

    if ( ! file_exists(APPPATH.'/views/truelove_view/'.$page.'.php'))
    {
        // Whoops, we don't have a page for that!
        show_404();
    } 

        $this->load->view('truelove_view/templates/header.php');
        $this->load->view('truelove_view/'.$page);   
        $this->load->view('truelove_view/templates/footer.php');    

当我包含$ this-> load-> helper(' url');在view()中代码可以正常工作,但是当我将它包含在构造函数中时,它就没有了。如果我自动加载url helper也可以。

有什么想法吗?

2 个答案:

答案 0 :(得分:4)

在提供的代码中,您有public function _construct(),但应该是public function __construct()。您需要添加双下划线__

答案 1 :(得分:0)

使用数组加载助手:

$this->load->helper( array('url') );
相关问题