如何使用"root" PHP的命名空间? [英] How to use "root" namespace of php?
本文介绍了如何使用"root" PHP的命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Exception类:
I have an Exception class:
namespace abc;
class AbcException extends Exception {
// blah blah
}
它会产生此错误:
Class 'abc\Exception' not found ...
问题:
-
我该怎么做才能使它起作用?
What can I do to make this work ?
感谢您提供有用的文档.
Useful documents are appreciated.
感谢您阅读我的问题
推荐答案
我该怎么做才能使它起作用?
What can I do to make this work ?
使用前导反斜杠表示全局名称空间:
Use a leading backslash to indicate the global namespace:
namespace abc;
class AbcException extends \Exception {
// blah blah
}
感谢您提供有用的文档.
Useful documents are appreciated.
在PHP中有整个页面专门用于此内容手动!
There's an entire page devoted to this in the PHP manual!
这篇关于如何使用"root" PHP的命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文