<?php
/*
别名和导入可以看做是调用 命名空间的一种快捷方式,php并不 支持导入函数或者常量
*/
namespace BlogArticle;
class Comment{
function test(){
return 'aaa';
}
}
//创建一个BBS空间
namespace BBS;
//导入一个命名空间
use Blog/Article;
//导入命名空间后可使用限定名称调用元素
$artcle_comment = new ArticleComment();
echo $artcle_comment->test();
echo '<br/>';
//为命名空间使用别名
use Blog/Article as Arte;
$artcle_cpmment = new ArteComment();
echo $artcle_comment->test();
echo '<br/>';
//导入一个类
use BlogArticleComment;
$art_comment = new Comment();
echo $art_comment->test();
//为类使用别名
use BlogArticleComment as Comt;
//使用别名代替空间名
$art_comment = new Comt();
echo '<br/>';
echo $art_comment->test();