Home > Backend Development > PHP Tutorial > 求解下面代码有啥问题

求解下面代码有啥问题

WBOY
Release: 2016-06-23 13:12:19
Original
923 people have browsed it

是关于php自动加载文件的一段代码

public static function userAutoload($class_name) {		//先处理确定的(框架中的核心类)		// 类名与类文件映射数组		$framework_class_list = array(			// '类名' => '类文件地址'			'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',			) ;		//判断是否为核心类		if (isset($framework_class_list[$class_name])) {			//是核心类			require $framework_class_list[$class_name];			}		//判断是否为可增加(控制器类,模型类)		//控制器类,截取后是个字符,匹配Controller		elseif (substr($class_name, -10) == 'Controller') {			// 控制器类, 当前平台下controller目录			require CURRENT_CONTROLLER_PATH . $class_name . '.class.php';			}		//模型类,截取后5个字符,匹配Model		elseif (substr($class_name, -5) == 'Model') {			// 模型类,当前平台下model目录			require CURRENT_MODEL_PATH . $class_name . '.class.php';			}	}	/**	 * 注册自动加载	 */	private static function _initAutoload() {		spl_autoload_register(array(__CLASS__, 'userAutoload'));	}]
Copy after login


回复讨论(解决方案)

你在哪里调用 _initAutoload 方法的?

你在哪里调用 _initAutoload 方法的?


在当前类的另一个方法中 通过 static::_initautoload调用了

已经解决 是自动加载大小写问题

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template