Hi,
This is how I autoload all the classes in my `controllers` folder,
But I have classes in `models` folder as well and I want to autoload them too - what should I do? Should I duplicate the autoload above and just change the path to `models/` (but isn't this repetitive??)?PHP Code:# auto load controller classes
function __autoload($class_name)
{
$filename = 'class_'.strtolower($class_name).'.php';
$file = AP_SITE.'controllers/'.$filename;
if (file_exists($file) == false)
{
return false;
}
include ($file);
}
These are my classes file names in the controller folder:
these are my classes file names in the model folder:Code:class_controller_base.php class_controller_factory.php etc
this is how I name my controller classes class usually (I use underscores and lowcaps),Code:class_model_page.php class_model_parent.php etc
this is how I name my model classes class usually (I use underscores and lowcaps),PHP Code:class controller_base
{
...
}
class controller_factory
{
...
}
Thanks.PHP Code:class model_page
{
...
}
class model_parent
{
...
}






Bookmarks