PHP 命名空间笔记
PHP 命名空间笔记 1.php文件代码如下 <pre> <?php //我用这样的命名空间表示处于blog下的article模块 namespace Blog\Article; class Comment { function __construct(){ //初始化对象,将初始化值放在括号内 echo'初始化1'; } } ?> </pre> 2.php文件代码如下 <pre> <?php require '1.php'; //调用Blog\Article空间的类 $article_comment = new \Blog\Article\Comment(); /*require '1.php'; use Blog\Article\Comment; $article_comment = new Comment();*/ /*namespace Blog\Article; require '1.php'; $article_comment = new Comment();*/ ?> </pre> 来源: https://www.cnblogs.com/newmiracle/p/11873105.html