定义子命名空间
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
与目录和文件的关系很象,PHP 命名空间也允许指定层次化的命名空间的名称。因此,命名空间的名字可以使用分层次的方式定义:
示例 #1 声明分层次的单个命名空间
<?php
namespace MyProject\Sub\Level;
const CONNECT_OK = 1;
class Connection { /* ... */ }
function connect() { /* ... */ }
?>
MyProject\Sub\Level\CONNECT_OK
,类
MyProject\Sub\Level\Connection
和函数
MyProject\Sub\Level\connect
。

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/language.namespaces.nested.php