Questions about PHP class loading under namespaces

Source: Internet
Author: User
Keywords Php
Tags autoloader spl

  
   

问一下大家自动装载是自动加载的意思吗,就是会调用spl_autoload_register()之类的函数。

Reply content:
 !--? phpnamespace a;use b\d, c\e as F;new B ()    ; Create an object of class ' B ' defined in namespace ' A '//If not found, try to automatically load class "a\b"   

Ask everyone if automatic loading is automatic loading means that it will call SPL Functions such as _autoload_register ().

Auto Mount here should be auto load The meaning of the . But Spl_autoload_register is not called at the time of New B () -it should have been called before. new B () is automatically loaded simply by invoking the autoloader registered with Spl_autoload_register in the order in which it was previously registered.

For example, there has been a previous registration of two autoloader:

spl_autoload_register (foo ); Spl_autoload_register (bar);  

Then call foo at new B () after calling bar ...

For more information about Spl_autoload_register , please refer to: http://php.net/manual/zh/function.spl-autoload-register.php

  • 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.