2015-02-09 56 views
0

我想從核心 這裏創造了一些控制,並從和庫調用它會exstends是 我控制器爲什麼我無法在Codeigniter.2.2.1上從我的控制器中選擇控制器?

<?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'); 
     } 
    } 
    ?> 

,這裏是Frontend_Controller在lirbray

class Frontend_Controller extends MY_Controller{ 

       public function __construct() { 
        parent::__construct(); 
       } 
    } 

這是MY_Contr Codeigniter2.2.0

+0

因爲你想擴展類「MY_Controllers,和你的控制器不是」 MY_Controllers它My_Controller,看到了嗎? – 2015-02-09 14:51:31

+0

哦,我在這個頁面寫錯了,但它是我的項目相關 – asdfasdf 2015-02-09 14:52:20

+0

page.php第3行是什麼? – 2015-02-09 14:53:56

回答

0

是工作完美的:奧勒在覈心

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 

正是在錯誤Codeigniter2.2.1
注意事項Frontend_Controller不應該是一個庫。您需要將其與my_controller一起放入應用程序的核心文件夾中,然後將自動加載器添加到my_controller。

這種自動加載機添加到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 */ 
+0

與舊版權不同。因爲當我使用這段代碼時,它將與舊版本 – asdfasdf 2015-02-09 15:12:13

+0

一起工作但是現在,當我將Core更改爲庫時,如果將我的frontend_Controller放入庫中,它將起作用 – asdfasdf 2015-02-09 15:15:13

+0

2.2.1僅是次要更新,因此不會引入任何突破性的更改。如果你的代碼在2.2.0中工作,那麼它應該在2.2.1中工作,據我所知。當您升級到2.2.1時,您是否確保繼續進行任何系統級別的更改?您可以閱讀完整的更新日誌** [這裏](http://www.codeigniter.com/user_guide/changelog.html)** – MonkeyZeus 2015-02-09 15:16:49

相關問題