CodeIgniter - get error messages

∥☆過路亽.° 提交于 2019-12-08 07:38:32

Well, actually, two things:

1) In your re-routed 404 page, you should be able to pass regularly any variable you want, so you can simply $this->load->view('parts/_404',$data); and have there available your variables.

2) if you're talking about the default 404 page, keep in mind that it can't be overridden under certain circustamces, that is when the show_404() core function is called:

It won't affect to the show_404() function, which will continue loading the default error_404.php file at application/errors/error_404.php.

This function belongs to the Exception handler class. There, in fact, at line 90 you have

function show_404($page = '', $log_error = TRUE)
    {
        $heading = "404 Page Not Found";
        $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', '404 Page Not Found --> '.$page);
        }

        echo $this->show_error($heading, $message, 'error_404', 404);
        exit;
    }

which in turn calls the show_error() method wich sets the header error code (4th argument) and adds the specified view (3rd argument) to the view buffer.

As you can see messages are here hardcoded inside the method. If you want a total customization you can either override this method (make it, for example, call another function within the same class) or simply hardcode other message there instead.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!