Php APPPATH未拾取子目录Codeigniter
嗨,我正在处理我的库文件,但目前它只能拾取文件夹中的控制器文件。我需要它能够拿起,如果控制器在子文件夹 库文件Php APPPATH未拾取子目录Codeigniter,php,codeigniter,Php,Codeigniter,嗨,我正在处理我的库文件,但目前它只能拾取文件夹中的控制器文件。我需要它能够拿起,如果控制器在子文件夹 库文件 function controller($file_name){ $CI = & get_instance();$file_path = APPPATH.'controllers/'.$file_name.'.php'; $object_name = $file_name; $class_name = ucfirst($file_name);if(file_exists($fi
function controller($file_name){
$CI = & get_instance();$file_path = APPPATH.'controllers/'.$file_name.'.php';
$object_name = $file_name;
$class_name = ucfirst($file_name);if(file_exists($file_path)){
require $file_path;
$CI->$object_name = new $class_name();
} else {
show_error('Unable to load the requested controller class:'.$class_name);
}
}
范例
控制器
public function __construct() {
parent::__construct();
$this->load->library('action');
$this->load->controller('header'); <--works
$this->load->controller('common/header'); <-- Not Working Not Picking up the subfolder header is file.
}
如果它是一个库,可能$this->load->library'xxxxxx';不发布答案,因为我不知道。在我自己的代码中,我有子目录,它们可以工作,例如,这对我来说很有用:$this->load->model'tank_auth/users';为什么不看看CIs Loader classI呢?我现在已经用它完成了,但是它的控制器功能仍然不允许我在控制器中拾取子文件夹。如果您需要在彼此内部加载控制器,那么您的逻辑有问题。