php命名空间示范

<?php
//一个文件里两个命名空间
namespace Article;
class comment{
function test(){
return 'aaa';
}
}

namespace MessageBoard;
class Comment{
function test(){
return 'www';
}
}

$comment = new comment();
$a = new \MessageBoard\Comment();
echo $a->test();

$obj = new \Article\Comment();
echo $obj->test();
?>

posted @ 2017-03-02 13:32  yahn~  阅读(112)  评论(0编辑  收藏  举报