未命名

admin3年前IT技术1165

<?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();?>


相关文章

在build 里点击clean project就可以解决路上问题

 es/color/material_on_surface_disabled.xml在build 里点击clean project就可以解决y问题...

掌握了excel宏开发,开心一下

步骤1.保存为支持宏命令的excel格式2.先录制,3.把重复的操作用for to next的语句段写出来案例如下:Sub Macro5() For i = 9 To 10073  ...

Android Studio下载sdk失败的解决方案

在浏览器打开这个网站http://ping.chinaz.com/dl.google.com或者:https://www.ping.cn/ping/dl.google.com他会列出一个ip列表,挨个...

dell G15游侠重装系统

https://www.dell.com/support/kbdoc/zh-cn/000176966/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%88%B4%E5%B0%94%E8%...

php DOMXPath抓取div标签的值的方法

 <?php $url="####";$amz_url=file_get_contents($url);$dom = new DOMDocument();...

win server 2008安装IIS的支持ACCESS的方法

1.设置windows/temp权限  添加user可读写权限2.设置程序池兼容32位3.设置ASP父路径为true...

发表评论    

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