spl_autoload_register和扩展功能之间的优先级? [英] Priority between spl_autoload_register and extension's function?

查看:91
本文介绍了spl_autoload_register和扩展功能之间的优先级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 composer 来管理我的依赖项和类加载.该工具使用spl_autoload_register功能.

我想使用PHP的扩展,该扩展提供的某些类与通过 composer 定义的其他类具有相同的定义(名称,命名空间,函数).

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.

PHP将加载哪个类?扩展名是一个,还是自动加载是一个,或者PHP的组件是未定义的?

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

推荐答案

PHP将使用扩展名的扩展名.这是因为仅当您尝试访问尚不存在的类时,才会发生自动加载.扩展功能和类将在PHP启动后存在,这意味着在代码开始运行之前.

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.

这篇关于spl_autoload_register和扩展功能之间的优先级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆