PHP自动加载
//------------------------- 自动加载Modules,Service类库 --------------------------// spl_autoload_register(function($ClassName){ if(!function_exists('ClassAutoLoad')){ function ClassAutoLoad($RootDir,$ClassName){ $DirList=dir($RootDir); while($DirName=$DirList->read()){ if($DirName!='.' && $DirName!='..' && is_dir($RootDir.$DirName)){ if(file_exists($RootDir.$DirName.'/Class.'.$ClassName.'.php')){ include_once($RootDir.$DirName.'/Class.'.$ClassName.'.php'); return true; }else{ ClassAutoLoad($RootDir.$DirName.'/',$ClassName); } } } } } $DirArr=array('Modules','Service'); foreach($DirArr as $DVal){ if(ClassAutoLoad(SYSTEM_ROOTPATH.'/'.$DVal.'/',$ClassName)){ break; } } });