Home > Backend Development > PHP Tutorial > __autoload function in PHP automatically loads class files_PHP tutorial

__autoload function in PHP automatically loads class files_PHP tutorial

WBOY
Release: 2016-07-13 10:31:55
Original
1037 people have browsed it

, automatic loading mechanism
function __autoload() { //
$path = str_replace('_', '/', $class_name);
require_once $path . '.php';
}
// The Http/File/Interface.php file will be automatically loaded here
$a = new Face();

When a class is instantiated, the corresponding class file will be loaded

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/760668.htmlTechArticle, automatic loading mechanism function __autoload( ) { // $path = str_replace('_', '/', $class_name); require_once $path . '.php'; } // The Http/File/Interface.php file will be automatically loaded here...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template