Which of the following experts can help me explain how to automatically load classes?

Source: Internet
Author: User
Tags autoload
Who can help me explain how to automatically load the class/* require (ROOT. 'include/db. class. php '); require (ROOT. 'include/conf. class. php '); require (ROOT. 'include/log. class. php '); require (R, who can help me explain how to automatically load classes?

/*
Require (ROOT. 'include/db. class. php ');
Require (ROOT. 'include/conf. class. php ');
Require (ROOT. 'include/log. class. php ');
Require (ROOT. 'include/mysql. class. php ');
Require (ROOT. 'model/Model. class. php ');
Require (ROOT. 'model/TestModel. class. php ');
*/


Function _ autoload ($ class ){
If (strtolower (substr ($ class,-5) = 'model '){
Require (ROOT. 'model/'. $ class.'. class. php ');
} Else {
Require (ROOT. 'include/'. $ class.'. class. php ');
}
}
The above deregistered is the manual loading class, and the following is the automatic loading

I don't quite understand where the $ class comes from
------ Solution --------------------
When you use new classname
If the classname class does not exist, php will call the _ autoload function and pass the classname
------ Solution --------------------
$ Class is the class name that cannot be found
The automatically loaded class is the class that cannot be automatically loaded.

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.