Home >php教程 >php手册 >php中 __autoload函数 自动加载类文件机制

php中 __autoload函数 自动加载类文件机制

WBOY
WBOYOriginal
2016-06-13 09:37:091294browse

,自动加载机制
function __autoload() {   //
$path = str_replace('_', '/', $class_name);
require_once $path . '.php';
}
// 这里会自动加载Http/File/Interface.php 文件
$a = new Face();

 

当实例化类时就会加载相应的类文件

 

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