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

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

WBOY
Release: 2016-06-13 09:37:09
Original
1298 people have browsed it

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

 

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

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template