This article mainly shares with you a little knowledge about automatic loading of PHP classes. There is no need to manually add the require_once file, and the __autoload($class) function is used. I hope it can help everyone.
<?php spl_autoload_register('autoload1'); //'autoload'为定义的自动载入函数名 function __autoload1($class) { require_once __DIR__.'/'.$class.'.php'; } ?>
Related recommendations:
Auto-loading mechanism of PHP classes
php example tutorialphp automatic loading class usage example analysis
php class automatic loading method, php loading_PHP tutorial
The above is the detailed content of Automatic loading implementation method of PHP class. For more information, please follow other related articles on the PHP Chinese website!