我在 /application/core 中有一个控制器
/application/core/CMS_Controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH."third_party/MX/Controller.php";
class CMS_Controller extends MX_Controller {
public function __construct() {
parent::__construct();
}
public function show_something() {
echo "something shown";
}
}
我在从 CMS_Controller 扩展的模块(/modules/my_module/controllers/controller.php)中有另一个控制器
/modules/my_module/controllers/controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Controller extends CMS_Controller {
public function index() {
$this->load->view('view');
}
}
而且,在 view.php (/modules/my_module/views/view.php) 我这样做: /modules/my_module/views/view.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$ci =& get_instance();
echo $ci->show_something();
?>
我得到这个错误:
致命错误:在第 3 行的 /home/gofrendi/public_html/No-CMS/modules/my_module/views/view.php 中调用未定义的方法 CI::show_something()
如果我不使用 MX_Controller 而是使用 CI_Controller 它将起作用: /application/core/CMS_Controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//require APPPATH."third_party/MX/Controller.php";
class CMS_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function show_something() {
echo "something shown";
}
}
有人知道这里有什么问题吗?