Home > php教程 > php手册 > 【伪】类自动加载

【伪】类自动加载

WBOY
Release: 2016-06-06 19:34:51
Original
1609 people have browsed it

用于类自动加载 PPPHP /** * 加载类库 * 会优先加载项目目录lib中的类 * @param str $lib 类名称 * @param str $dir like /Core/lib/ * @return obj */protected function b($lib){$systempath = CORE.'/lib/'.$lib.'.class.php';$apppath = APP.'/lib/'.$lib

用于类自动加载 PPPHP
	/**
	 * 加载类库
	 * 会优先加载项目目录lib中的类
	 * @param str $lib 类名称
	 * @param str $dir like /Core/lib/
	 * @return obj
	 */
	protected function b($lib)
	{
		$systempath = CORE.'/lib/'.$lib.'.class.php';
		$apppath = APP.'/lib/'.$lib.'.class.php';
		//引入lib
		if(file_exists($apppath)) 
		{
			include_once $apppath;
		}
		else
		{
			if(file_exists($systempath))
			{
				include_once $systempath;
			}
			else 
			{
				show_error('库'.$lib.'不存在');
			}
		}
		$lib = new $lib();
		return $lib;//返回OBJ
	}
Copy after login
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template