来源:未知 时间:2015-07-29 09:49 作者:xxadmin 阅读:次
[导读] 本文讲解php自动加载器类实现方法 这里autoload 可兼容以下格式: Cache_File_Json class_xxx.php xxx.class.php xxx.php php代码如下: function__autoload($className){$dirs=explode(_,$className);$fileName=array_pop($dir...
|
本文讲解php自动加载器类实现方法 这里autoload 可兼容以下格式: Cache_File_Json php代码如下: function __autoload($className){
$dirs=explode('_',$className);
$fileName=array_pop($dirs);
//print_r($dirs);
$filePath=$fileName;
if(is_array($dirs) && (count($dirs) > 0)){
//echo '\n---\n'; print_r($dirs);
$dirPath='';
foreach ($dirs as $dir){
if($dir){
$dirPath.=strtolower($dir).DIRECTORY_SEPARATOR;
}
}
$filePath=$dirPath.$fileName.'.php';
}else {
if( file_exists('class_'.$fileName.'.php')){
$filePath='class_'.$fileName.'.php';
}else {
if( file_exists($fileName.'.class.php')){
$filePath=$fileName.'.class.php';
} else {
$filePath=$fileName.'.php';
}
}
}
//var_dump($filePath);
require $filePath;
} |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com