How to add autoload-function to CodeIgniter?
问题 I would like to be able to use OOP and create new objects in my controllers in CodeIgniter. So I need to use an autoload-function: function __autoload( $classname ) { require_once("../records/$classname.php"); } But how can I add that to CodeIgniter? 回答1: You can add your auto loader above to app/config/config.php . I've used a similar autoload function before in this location and it's worked quite neatly. function __autoload($class) { if (strpos($class, 'CI_') !== 0) { @include_once(APPPATH