php类自动加载器实现方法
发布时间:2020-12-12 21:01:33 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解php类自动加载器实现方法。供大家参考研究。具体如下: 这里autoload 可兼容以下格式: Cache_File_Json class_xxx.php xxx.class.php xxx.php php代码如下: 0)){ //echo 'n---n'; print_r($dirs); $dirPath=''; foreach ($dirs as $
本篇章节讲解php类自动加载器实现方法。分享给大家供大家参考。具体如下: 这里autoload 可兼容以下格式: Cache_File_Json class_xxx.php xxx.class.php xxx.php php代码如下: 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程序设计有所帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |