PHP spl_autoload

后端 未结 3 1704
借酒劲吻你
借酒劲吻你 2021-01-05 14:24

i dont really get the docs for spl_autoload

bool spl_autoload_register  ([ callback $autoload_function  ] )

from my understanding, it will

3条回答
  •  北海茫月
    2021-01-05 15:18

    Your entire statement is correct.

    spl_autoload_register allows you to register multiple autoload functions. In the case that you try to create or use an object of a class that has not been loaded into the PHP environment, PHP will run all your autoload functions looking for that class.

    The Doctrine example you give is using what is called a callback to register a method inside of a class. A callback is simply an array containing the class name (for static methods) or an instance of that class (for non-static methods), and the method name.

提交回复
热议问题