zhphp framework (五) 框架加载类
2015-12-11 13:23
585 查看
<?php /** * Created by PhpStorm. * User: 张华 * Date: 2015/8/27 * Time: 1:12 * * QQ: 746502560@qq.com * To change this template use File | Settings | File Templates. */ defined('IN_ZHPHP')?NULL:die('attempts to hack the system'); if(function_exists('spl_autoload_register')){ spl_autoload_register(array('loader', 'autoload')); } else { function __autoload($className) { return loader::autoload($className); } } final class loader { private function __construct() {}#防止被实例化 public static function init(){ $files=self::loadSysConf(); $includePath=implode(PATH_SEPARATOR,$files); set_include_path($includePath.PATH_SEPARATOR.get_include_path()); } public static function autoload($className){ if(class_exists($className) === false){ //解决smarty 自动加载冲突 if(preg_match('/Smarty/i',$className)){ return; } $file=$className.'.class.php'; include_once $file; } } private static function loadSysConf(){ $_src=array( ROOT_PATH.'core/', ROOT_PATH.'engine/', ROOT_PATH.'engine/factory/', ROOT_PATH.'library/', ROOT_PATH.'extends/Tpl/Smarty/', APP_PATH.'models/', APP_PATH.'controllers/', APP_PATH.'controllers/components/', APP_PATH.'widget/', APP_PATH.'modules/' ); return $_src; } }
相关文章推荐
- zhphp framework (四)动态加载应用程序产量,方便任何程序代码重构
- zhphp framework (三) 框架工作流程
- ThinkPHP
- 夺命雷公狗---PHP---玩转安卓2之扫码进行登录原理
- php laravel 帧 该文件上传
- php创建空对象
- Gearmand和PECL extension for Gearman版本不兼容的问题
- php扩展名获取函数
- php利用pdo进行mysql的事务处理机制
- phpstorm移除已创建的项目
- PHP漏洞全解(六)-Session劫持
- PHP漏洞全解(四)-SQL注入攻击
- php通过curl模拟功能总结
- php 自带过滤和转义函数
- PHP漏洞全解(三)-xss跨站脚本攻击
- PHP漏洞全解(二)-客户端脚本植入
- iOS程序猿如何快速掌握 PHP,化身"全栈攻城狮"?
- PHP DATE( )函数与系统时间差8小时解决办法
- php empty()和isset()
- IIS下安装Mantis所需环境的配置