未命名

admin3年前IT技术1077

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


相关文章

汇成免费订单系统V11.5

汇成免费订单系统V11.5***********************************声明:本系统永久免费!!!***********************************官方下载...

windows 10清除系统盘,增加系统盘空间的方法

管理员模式cmd  执行 powercfg.exe /hibernate off虚拟内存大小设置为100-120MB     &n...

linux 挂载win7共享文件夹的方法

mount -t cifs -o user=administrator,password=000000 //192.168.1.2/gongxiang /mnt/share...

asp移动APP单页应用开发前端后端框架v1.0

asp移动APP单页应用开发前端后端框架v1.0简称aspwn  1.0在线演示 ˂a href="download/aspwn.zip" target="_blank"˃官方下载开发此套框...

关于jquery升级至1.8版本之后的兼容问题Uncaught TypeError: $(...).size is not a function

关于jquery升级至1.8版本之后的兼容问题Uncaught TypeError: $(...).size is not a function

之前也遇到过这种问题Uncaught TypeError: $(...).size is not a function  控制台报错如上图,打开Frame.js可以看到里面定义大小...

删除系统还原点,可以释放大量c盘空间

删除系统还原点,可以释放大量c盘空间

删除系统还原点,可以释放大量c盘空间...

发表评论    

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