Phil의 철갑 상어 example에 이어 ./application/libraries 폴더에 Public_Controller와 Admin_Controller라는 두 개의 컨트롤러를 만들었습니다.CodeIgniter 자동로드 특정 클래스
내가 뭘 원하는 내가 더 많이 가지고있는 Public_Controller 및 Admin_Controller specificly 자동로드에, 그래서 ./application/config.php
function __autoload($class) {
// Autoload only Public_Controller and Admin_Controller
if (strpos($class, 'CI_') !== 0) {
$file = APPPATH . 'libraries/'. $class .'.php';
if (file_exists($file) && is_file($file)) {
@include_once($file);
}
}
}
내 생각이의 문제점 안쪽이 자동로드 기능을 생성 라이브러리 폴더에 포함 된 파일들도 자동으로로드되므로 원하는 것은 아닙니다. 그래서 그 대신 내가 문 경우,이 같은 처음에 작은 변화하려고 노력 : 단지이 두 클래스를 대상으로하기 위해
if (in_array($class, array('Public_Controller, Admin_Controller'))) // instead of strpos
을,하지만이 작동하지 않습니다. 내가 뭘 잘못했을지 모르는 어떤 아이디어?
그러면 다음과 같이 할 수 있습니다 : 원하는 컨트롤러의 내부에서'$ this-> load-> model ('Model_name'); – Albzi