1 Star 0 Fork 282

walkskyer / LaneWeChat

forked from Lane / LaneWeChat 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
autoloader.php 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
lane 提交于 2014-11-05 17:34 . 1.4版本发布
<?php
namespace LaneWeChat;
/**
*
* 自动载入函数
* Created by Lane.
* User: lane
* Date: 14-10-15
* Time: 下午6:13
* E-mail: lixuan868686@163.com
* WebSite: http://www.lanecn.com
*/
class Autoloader{
const NAMESPACE_PREFIX = 'LaneWeChat\\';
/**
* 向PHP注册在自动载入函数
*/
public static function register(){
spl_autoload_register(array(new self, 'autoload'));
}
/**
* 根据类名载入所在文件
*/
public static function autoload($className){
$namespacePrefixStrlen = strlen(self::NAMESPACE_PREFIX);
if(strncmp(self::NAMESPACE_PREFIX, $className, $namespacePrefixStrlen) === 0){
$className = strtolower($className);
$filePath = str_replace('\\', DIRECTORY_SEPARATOR, substr($className, $namespacePrefixStrlen));
$filePath = realpath(__DIR__ . (empty($filePath) ? '' : DIRECTORY_SEPARATOR) . $filePath . '.lib.php');
if(file_exists($filePath)){
require_once $filePath;
}else{
echo $filePath;
}
}
}
}
1
https://gitee.com/walkskyer/LaneWeChat.git
git@gitee.com:walkskyer/LaneWeChat.git
walkskyer
LaneWeChat
LaneWeChat
master

搜索帮助