未命名

admin3年前IT技术1435

<?php

namespace Article;

class Comment { }


namespace MessageBoard;

class Comment { }


//调用当前空间(MessageBoard)的Comment类

$comment = new Comment();


//调用Article空间的Comment类

$article_comment = new \Article\Comment();

?>


别名和导入

别名和导入可以看作是调用命名空间元素的一种快捷方式。PHP并不支持导入函数或常量。

它们都是通过使用use操作符来实现:

<?phpnamespace Blog\Article;class Comment { }//创建一个BBS空间(我有打算开个论坛)namespace BBS;//导入一个命名空间use Blog\Article;//导入命名空间后可使用限定名称调用元素$article_comment = new Article\Comment();//为命名空间使用别名use Blog\Article as Arte;//使用别名代替空间名$article_comment = new Arte\Comment();//导入一个类use Blog\Article\Comment;//导入类后可使用非限定名称调用元素$article_comment = new Comment();//为类使用别名use Blog\Article\Comment as Comt;//使用别名代替空间名$article_comment = new Comt();?>


相关文章

php缓存技术

<?php for($i=0;$i<=5;$i++){echo $i."<br/>";ob_flush();//这里是刷新php缓冲区flush();//这...

搭建apache2.4+php5.6环境

工具下载地址apache2.4 下载地址:http://httpd.apache.org/php5.6 下载地址:http://windows.php.net/download#php-5.6一、安装...

ubuntu 远程连接 22 端口

安装OpenSSHUbuntu缺省没有安装SSH Server,使用以下命令安装:sudo apt-get install openssh-server openssh-client不过Ubuntu缺...

MYSQL带存储过程备份命令

命令中要加-R mysqldump -u root -p -R 数据库名称 > 备份文件名.sql...

解决方案2
打开的本地组策略

Win10远程连接的凭据不工作的解决方法

 把远程桌面工具的本地资源的打印机与剪贴板的勾勾取消解决方案2打开的本地组策略在右侧打开的窗口中双击“网络访问:本地账户的共享和安全模型”一项在打开的属性窗口中,我们...

ps蒙版失灵的解决方案,ps蒙版失灵的解决方法

ps蒙版失灵的解决方案,ps蒙版失灵的解决方法

 选中蒙板层后,这个点交换下试试  ...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。