Home > php教程 > php手册 > body text

PHP 命名空间实例说明

WBOY
Release: 2016-06-06 20:35:51
Original
867 people have browsed it

PHP 命名空间实例说明,需要的朋友可以参考下。

复制代码 代码如下:


namespace bak\ba\ba;
function bab(){
echo "bi";
}
namespace kkk;
function k1(){
echo "k1";
}
\bak\ba\ba\bab();//在kkk的命名空间下使用别的命名空间,注意前面的\
use \bak\ba\ba as b;//依旧在kkk的命名空间下,但是用别名的的时候以下方法也正确
#use bak\ba\ba as b;//前面可以不使用\号
b\bab();//使用别名下命名空间的时候前面不该有\号
k1();//调用该函数没有报错,说明use不影响当前当前命名空间

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!