• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP有没有USE这个关键词解决方案

php 搞代码 3年前 (2022-01-23) 12次浏览 已收录 0个评论

PHP有没有USE这个关键词
我看的一些PHP的资料好像都没有USE。但是刚才看一个框架时发现里面用到了USE。

——解决方案——————–
我猜 没有吧
——解决方案——————–
这个不明白啊
——解决方案——————–
<?php
namespace foo;
use My\Full\Classname as Another;

// this is the same as use My\Full\NSname as NSname
use My\Full\NSname;

// importing a global class
@本文9来源gao($daima.com搞@代@#码8网^搞代gaodaima码use ArrayObject;

$obj = new namespace\Another; // instantiates object of class foo\Another
$obj = new Another; // instantiates object of class My\Full\Classname
NSname\subns\func(); // calls function My\Full\NSname\subns\func
$a = new ArrayObject(array(1)); // instantiates object of class ArrayObject
// without the “use ArrayObject” we would instantiate an object of class foo\ArrayObject
?>
好像是给一个类定义别名:如下

use class3 as Another;
use class3 as Another1;
use class3 as Another2;

$obj = new Another; //
$obj = new Another1; //
$obj = new Another2; //

——解决方案——————–
php 5.3+


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP有没有USE这个关键词解决方案

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址