The working mechanism of PHP auto load _ autoload. When using the php oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, in the
When using the php oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance. This is
When developing a system using the PHP OO model, it is often customary to store each class's implementation in a separate file, which makes it easy to reuse the classes and facilitate future maintenance.
I. Overview of the AUTOLOAD mechanismWhen
PHP AutoLoad Mechanism detailed
(1) AutoLoad mechanism overview
When developing a system using the PHP OO model, it is often customary to store the implementation of each class in a separate file, which makes it easy to reuse the classes and
PHP before the Magic Function __autoload () method appears, if you want to instantiate 100 objects in a program file, you must include 100 class files with include or require, or you could define these 100 classes in the same class file-- I believe
__autoload implementation of automatic loading, but due to the introduction of a multi-class library, __autoload Maintenance will be complex, the introduction of SPL_AOTOLOAD,SPL implementation of an automatic loading function list of manual
PHP provides Autoload to help us easily include files, but autoload does not handle all situations as imagined, today, we will record some problems with autoload that we encountered a few days ago.
Why use Autoload?
When using a class in PHP, We
PHP provides autoload to help us facilitate the inclusion of files, but AutoLoad is not as capable of handling all the situations as it is, and today it's time to take a look at some of the autoload problems that have been encountered in the past
The AutoLoad function, like SPL, bloader the AutoLoad tool for PHP objects, but is simpler and more efficient and more flexible to configure.
Bloader provides a common autoload function, LD, and two auxiliary functions, ld_new (instantiation) and
Recently read a little laravel code, which used to composer, the feeling of the autoload mechanism is a bit weird, browsing the source code, there is income, so recorded.
After you use composer to download the package, you need to require
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.