PHP __autoload fails when there is a namespace (limitations of Use)

Source: Internet
Author: User

If you want to use the __autoload method, you can no longer use namespace,
With namespaces, at least php5.3 no longer calls the __autoload method
So if you need to use __autoload and namespaces, at least you can't use namespaces in a consolidated program
That is to say, namespace and __autoload function in a file can only use one
That is, if a namespace is used, file creation and access to an automatically loaded class can only be accessed using a named full name


The actual operation should invoke the Get Load list fetch function for the class load processing object in this function, return the load list, and load the add-in individually
This allows you to define the initial location of the load path, which is more convenient to load, but first to statically load the class file that loads the processing object (the object can be represented by a class static property in its file).
Because you can define the initial address, you can also change the rule to specify the address variation rules for the loaded File.


Automatic loading does not handle AOP programming, so app objects need to be able to automatically load processing class objects dynamically based on parameter definitions, and generate individual slice objects and register them in the call queue
Slice programming is actually an event-related programming that invokes the appropriate process at the right Time.

can be used

Spl_autoload_register instead

PHP __autoload fails when there is a namespace (limitations of Use)

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.