为什么我可以';t从Codeigniter上的“我的控制器”中删除控制器.2.2.1


Why I can't exstends controller from My controller on Codeigniter.2.2.1?

我想创建一些控制器,并从调用它,库将从Core退出这是我的控制器

  <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Page extends Frontend_Controller {
            public function __construct() {
                parent::__construct();
            }
        public function index()
        {
                $this->load->view('main/main_index');
        }
    }
    ?>

这是lirbray中的Frontend_Controller

 class Frontend_Controller extends MY_Controller{
                public function __construct() {
                    parent::__construct();
                }
     }

这是核心中的MY_Controller

 class MY_Controller extends CI_Controller{
                    public function __construct() {
                        parent::__construct();
                    }
         }

但是我得到了这个错误

Fatal error: Class 'MY_Controllers' not found in D:'My data'project'wamp'www'Ecom'application'controllers'page.php on line 3

这是Codeigner2.1
中的错误注意:它在Codeigner.2.0

上运行非常完美

Frontend_Controller不应该是库。您需要将其与my_controller一起放在应用程序的核心文件夹中,然后向my_controler添加一个自动加载器。

将此自动加载器添加到my_controller.php的末尾:

/**
 * -------------------------------------------------------------------
 *  Native Autoload - by Phil Sturgeon. New Version!
 * -------------------------------------------------------------------
 *
 * Nothing to do with config/autoload.php, this allows PHP autoload to work
 * for base controllers.
 */
function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0)
    {
        if (file_exists($file = APPPATH . 'core/' . $class . EXT))
        {
            include_once $file;
        }
    }
}

/* End of file MY_Controller.php */
/* Location: ./application/core/MY_Controller.php */