PHP 命名空间 namespace

  1. 声明: <?php // file1.php namespace MyProject; namespace MyProject\Sub\Level; //声明分层次的单个命名空间 namespace MyProject { const CONNECT_OK = 1; class Connection { /* … */ } function connect() { /* … */ } namespace Foo\Bar\subnamespace; const FOO = 1; function foo() {} class foo { static function staticmethod() {} } } ?>

  2. 使用