Php class automatic loading method, php loading _ PHP Tutorial

Source: Internet
Author: User
Tags spl
Php class automatic loading method, php loading. Php class automatic loading method, php class automatic loading method phpclassinload {*** class automatic loading, the developer does not need to call the ** @ paramstring $ class file * privat php class automatic loading method. php loads

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.

Http://www.bkjia.com/PHPjc/1011244.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1011244.htmlTechArticlephp class automatic loading method, php loaded php class automatic loading method phpclass inload {/*** class automatic loading, the developer does not need to call the ** @ param string $ class file */privat...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.