Php CodeIgniter未加载扩展MY_异常

Php CodeIgniter未加载扩展MY_异常,php,windows,codeigniter,Php,Windows,Codeigniter,我试图覆盖CI\u异常中的show\u 404方法,但从未加载MY\u异常 MY_Exceptions位于应用程序/core/ 这是密码 <?php class MY_Exceptions extends CI_Exceptions { function show_404(){ header("HTTP/1.1 404 Not Found"); $CI =& get_instance(); $CI->load->v

我试图覆盖
CI\u异常
中的
show\u 404
方法,但从未加载
MY\u异常

MY_Exceptions位于应用程序/core/

这是密码

<?php
class MY_Exceptions extends CI_Exceptions {
    function show_404(){
        header("HTTP/1.1 404 Not Found");
        $CI =& get_instance();
        $CI->load->view('header.php');
        $CI->load->view('err/custom404.php');
        $CI->load->view('footer.php');
    }
}
现在404页是空白的

编辑

解决方案 我们需要回显错误,而不是简单的加载视图

public function show_404($page = '', $log_error = TRUE){
    header("HTTP/1.1 404 Not Found");
    echo $this->CI->load->view('header.php',array('PAGE_TITLE'=>'Page not found'),true);
    echo $this->CI->load->view('err/custom404.php',null,true);
    echo $this->CI->load->view('footer.php',null,true);
    exit(4);
}
谢谢@Tpojka让我敞开心扉。

试试这个方法

<?
class MY_Exceptions extends CI_Exceptions
{
    public function __construct()
    {
        parent::__construct();
    }

    public function show_404($page = '', $log_error = TRUE)
    {
        if (is_cli())
        {
            $heading = 'Not Found';
            $message = 'The controller/method pair you requested was not found.';
        }
        else
        {
            $heading = '404 Page Not Found This Time';
            $message = 'The page you requested was not found.';
        }
        // By default we log this, but allow a dev to skip it
        if ($log_error)
        {
            log_message('error', $heading.': '.$page);
        }
        echo $this->show_error($heading, $message, 'custom404', 404);//custom404 is in APPPATH.'views/errors/html/custom404.php'
        exit(4); // EXIT_UNKNOWN_FILE
    }
}

我以这种方式更改,但得到相同的错误。我发现show_404的签名是不同的。现在调用了正确的方法,但显示了一个空白页。看起来视图是空的
<?
class MY_Exceptions extends CI_Exceptions
{
    public function __construct()
    {
        parent::__construct();
    }

    public function show_404($page = '', $log_error = TRUE)
    {
        if (is_cli())
        {
            $heading = 'Not Found';
            $message = 'The controller/method pair you requested was not found.';
        }
        else
        {
            $heading = '404 Page Not Found This Time';
            $message = 'The page you requested was not found.';
        }
        // By default we log this, but allow a dev to skip it
        if ($log_error)
        {
            log_message('error', $heading.': '.$page);
        }
        echo $this->show_error($heading, $message, 'custom404', 404);//custom404 is in APPPATH.'views/errors/html/custom404.php'
        exit(4); // EXIT_UNKNOWN_FILE
    }
}