Before PHP5, If PHP frameworks need to implement automatic class loading, they generally implement a traversal directory according to certain conventions and automatically load all classes or functions that comply with the agreed rules. Of course, PHP5's previous object-oriented support was not very good, and classes were not frequently used. Let's discuss it in detail. Php Automatic Loading Method
<? Phpclass inload {/*** class automatically loaded. You do not need to call ** @ param string $ class file */private function autoload ($ class) by the developer) {if (empty ($ class) {throw new QException ('loading file does not exist '. $ class);} else {require _ SPRING _. '/_ Core/SpringMap. php '; // framework map if (! File_exists ($ source [$ class] ['file']) {throw new QException ('file does not exist '. $ class) ;}require $ source [$ class] ['file'] ;}} /*** register or unregister an automatic class loading method ** for this method, refer to Zend Framework ** @ param string $ class to provide the class for automatic loading Service * @ param boolean $ enabled or disable the Service */private function registerAutoload ($ class = 'interpreter ', $ enabled = true) {if (! Function_exists ('spl _ autoload_register ') {throw new QException ('spl _ autoload does not have this PHP installation');} if ($ enabled = true) {spl_autoload_register (array ($ class, 'autoload');} else {spl_autoload_unregister (array ($ class, 'autoload '));}} /*** destructor */public function _ destruct () {self: registerAutoload ('interpreter', false );}
The above is all the content of this article. I hope you will like it.