What's the problem with the following code? a piece of code about php's automatic file loading
Public static function userAutoload ($ class_name) {// process the identified (core class in the framework) // class name and class file ing array $ framework_class_list = array (// 'class name' => 'class file address ''controller' => FRAMEWORK_PATH. 'controller. class. php', 'model' => FRAMEWORK_PATH. 'model. class. php ', 'Factory' => FRAMEWORK_PATH. 'factory. class. php', 'mysqldb' => FRAMEWORK_PATH. 'mysqldb. class. php', 'sessiondb' => TOOL_PATH. 'sessiondb. class. php ',); // determine whether it is a core class if (isset ($ framework_class_list [$ class_name]) {// It is a core class require $ framework_class_list [$ class_name];} // determine whether it can be added (controller class, model class) // controller class, which is followed by a character and matches Controllerelseif (substr ($ class_name,-10) = 'controller') {// Controller class, the current platform's controller directory require CURRENT_CONTROLLER_PATH. $ class_name. '. class. php ';} // Model class, which contains the last five characters and matches Modelelseif (substr ($ class_name,-5) = 'model') {// Model class, the model directory in the current platform is require CURRENT_MODEL_PATH. $ class_name. '. class. php ';}}/*** register to automatically load */private static function _ initAutoload () {spl_autoload_register (array (_ CLASS __, 'userautoload');}]
Reply to discussion (solution)
Where do you call the _ initAutoload method?
Where do you call the _ initAutoload method?
In another method of the current class, it is called through static: _ initautoload.
Fixed the case sensitivity issue for automatic loading.