I created two controllers: Public_Controller and Admin_Controller in the folder. / application / libraries, following the example of Phil Sturgeon.
What I want to do is automatically load Public_Controller and Admin_Controller, so I created this autoload function inside. /application/config.php
function __autoload($class) {
if (strpos($class, 'CI_') !== 0) {
$file = APPPATH . 'libraries/'. $class .'.php';
if ( file_exists($file) && is_file($file) ) {
@include_once($file);
}
}
}
The problem with this, I think, is that I have more files included in the libraries folder, so they also load automatically, which is not what I want. So instead, I tried to make a small change for the first if statement, for example:
if ( in_array($class, array('Public_Controller, Admin_Controller')) )
to focus only on these two classes, but that doesn't seem to work. Any ideas what I can do wrong?