Priority between spl_autoload_register and extension's function?

…衆ロ難τιáo~ 提交于 2019-12-11 03:37:07

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/28716313/priority-between-spl-autoload-register-and-extensions-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!