CodeIgniter: class 'CI_Controller' not found

I expanded the CodeIgniter controller by adding MY_Controller.php to the Application / Core folder. It works fine, but now when I add the following code to the page error_404.phpin Application/errors, I get an error.

The problem causing the code:

<?php $ci =& get_instance();?>
<?php $this->ci->load->view('header')?>

Error:

Fatal error: Class 'CI_Controller' not found in path\to\system\core\CodeIgniter.php on line 231

Line 231 system\core\CodeIgniter.php:

function &get_instance()
    {
        return CI_Controller::get_instance(); 
    }

How can I fix this to load the view into the error_404.php file without changing anything in the system files.

PS. I am using the latest version.

Thank.

+5
source share
4 answers

I do not think CI_Controller is loaded. The Exception class handles 404 page output with include.

include, file_get_contents() cURL 404- URL-, , , - . 2.0 404 routes.php:

$route['404_override'] = 'controller/method/parameter';

- , - .

, base_url()."controller/method/parameter" URL-, , 404 , ( - ).

+4

, CodeIgniter: http://codeigniter.com/user_guide/tutorial/static_pages.html

, URL:

/CodeIgniter_2.1.1///pages.php

URL:

/CodeIgniter_2.1.1/index.php//

, 18 , , , , - :)

+4

or you can try it, maybe the bit is dirty, but I think it will work for me.

update your exception to

function show_404($page = '', $log_error = TRUE)  {
   if ($log_error)   {
     log_message('error', '404 Page Not Found --> '.$page); 
   } 
   header('Location: http://www.########.###/error/error_404');  
   die();
}

then just create a controller to handle redirection, maybe with different errors you can use the same controller

this way you get your dynamic header and footer

+4
source

Try:

<?php $ci =& get_instance();?>
<?php $ci->load->view('header')?>

Once you have assigned the CI instance to $ ci, you can simply use $ ci-> load-> view ('header) in your file.

0
source

All Articles