Priority between spl_autoload_register and extension's function?

I use composer to manage my dependencies and class loading. This tool uses spl_autoload_register function.

I would like to use a PHP's extension that provides some classes with same definition (name, namespacing, functionnalities) than others classes defined throught composer.

Which class will PHP load? The extension's one, or the autoload's one, or maybe the PHP's comportment is undefined?

Answer1:

PHP will use the extension's one. This is because autoloading will only happen if you are attempting to access a class which does not already exist. Extension functions and classes will exist after PHP's startup meaning before the code starts to run.

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Priority between spl_autoload_register and extension's function?