php类自动加载器
php类自动加载器 兼容以下格式 Cache_File_Json class_xxx.php xxx.class.php xxx.php```{.php}function __autoload($className){$dirs=explode(#39;_#39;,$className);$fileName=array_pop($dirs);//
兼容以下格式
Cache_File_Json
class_xxx.php
xxx.class.php
xxx.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解析RSS的类实现
精彩图集
精彩文章