我認爲你已經把你的MY_Controller放在/ application/core中,並在config中設置前綴。 雖然我會小心使用索引作爲類名。作爲Codeigniter中的函數/方法,它有一個專門的行爲。
如果您希望擴展該控制器,則需要將這些類放在同一個文件中。
例如在/應用程序核心
/* start of php file */
class MY_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
}
...
}
class another_controller extends MY_Controller {
public function __construct() {
parent::__construct();
}
...
}
/* end of php file */
在/應用/控制器
class foo extends MY_Controller {
public function __construct() {
parent::__construct();
}
...
}
或
class bar extends another_controller {
public function __construct() {
parent::__construct();
}
...
}
我問同樣的問題[這裏] [1] [1]:http://stackoverflow.com/questions/7982187/codeigniter-extending-common-controller 希望它可以幫助 – luso