php spl_autoload_register vs __autoload?

后端 未结 2 1499
轻奢々
轻奢々 2020-12-05 02:19

hello is there any diffrence useing this excepts that we can use our own name auto load? is there any performance difference? how do they internally work?

between

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 03:06

    Documentation for "Autoloading Classes" reads:

    spl_autoload_register() provides a more flexible alternative for autoloading classes. For this reason, using __autoload() is discouraged and may be deprecated or removed in the future.

    Documentation for spl_autoload_register() reads:

    If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined. By contrast, __autoload() may only be defined once.

提交回复
热议问题