且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP 在全局命名空间中使用类

更新时间:2023-11-19 19:07:10

解决了.我没有意识到命名空间别名仅适用于当前文件,而不适用于任何未来包含的文件.在 PHP.net 上发现这也适用于别名:

Solved it. I didn't realize that aliasing a namespace only applies to the current file, and not any future included files. Found this on PHP.net which also applies to aliasing:

导入规则是基于每个文件的,这意味着包含的文件不会继承父文件的导入规则.

Importing rules are per file basis, meaning included files will NOT inherit the parent file's importing rules.