Home  >  Article  >  Backend Development  >  PHP _autoload函数知识点

PHP _autoload函数知识点

WBOY
WBOYOriginal
2016-06-13 12:27:42869browse

PHP __autoload函数知识点

__autoload函数主要是用来包含不存在的类文件,当初始化的类不存在的时候

function __autoload($param){
$file = $param.'.php';
if(file_exists($file)){
require_once $file;
}
}
//实例化footer类的时候会,没有找到footer类,自动调用__autoload加载文件
$obj = new footer();

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