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

__autoload function in PHP automatically loads class files_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:31:55990browse

, 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...
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