Home >Backend Development >PHP Tutorial >_autoload函数加载的文件夹多,网站流量又大,那么对速度影响大么,该怎么解决

_autoload函数加载的文件夹多,网站流量又大,那么对速度影响大么,该怎么解决

WBOY
WBOYOriginal
2016-06-13 10:25:47843browse

__autoload函数加载的文件夹多,网站流量又大,那么对速度影响大么
__autoload函数加载的文件夹多,网站流量又大,那么对速度影响大么!
function __autoload($className){
if(file_exists('model/'.$className.'.class.php')){
include_once('model/'.$className.'.class.php');
}
if(file_exists('Controller/'.$className.'.class.php')){
include_once('Controller/'.$className.'.class.php');
}

$prefix=$GLOBALS['groupName']=='main'?'':'../';
if(file_exists($prefix.'core/'.$className.'.class.php')){
include_once($prefix.'core/'.$className.'.class.php');
}
if(file_exists($prefix.'core/Smarty-3.1.6/'.$className.'.class.php')){
include_once($prefix.'core/Smarty-3.1.6/'.$className.'.class.php');
}
if(file_exists($prefix.'core/Smarty-3.1.6/sysplugins/'.$className.'.php')){
include_once($prefix.'core/Smarty-3.1.6/sysplugins/'.$className.'.php');
}

}

------解决方案--------------------
我认为用__autoload影响不大,因为也只是一次调用__autoload去加载多个文件,而不是多次调用__autoload去加载多个文件.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn