Doc #78659 [Opn->Nab]: 导入全局类

From: Date: Thu, 10 Oct 2019 19:29:28 +0000
Subject: Doc #78659 [Opn->Nab]: 导入全局类
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17001@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78659&edit=1

 ID:                 78659
 Updated by:         requinix@php.net
 Reported by:        513335394 at qq dot com
 Summary:            导入全局类
-Status:             Open
+Status:             Not a bug
 Type:               Documentation Problem
-Package:            PHP Language Specification
+Package:            Scripting Engine problem
 Operating System:   liunx
 PHP Version:        7.3.10
 Block user comment: N
 Private report:     N

 New Comment:

I think I can get this...

两者都被允许. "use ArrayObject" == "use \ArrayObject"
"use ArrayObject" 或 "new \ArrayObject" 是标准做法.

https://www.php.net/manual/zh/language.namespaces.php


Previous Comments:
------------------------------------------------------------------------
[2019-10-10 08:16:04] 513335394 at qq dot com

use ArrayObject;
和
use \ArrayObject;
应该使用哪一个?

------------------------------------------------------------------------
[2019-10-10 08:09:52] 513335394 at qq dot com

Description:
------------
---
From manual page: https://php.net/language.namespaces.importing
---

$a = new ArrayObject(array(1)); // 实例化 ArrayObject 对象
// 如果不使用 "use \ArrayObject"
,则实例化一个 foo\ArrayObject 对象


Test script:
---------------
use \ArrayObject 
use ArrayObject
都能引入全局类 



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=78659&edit=1


Thread (3 messages)

« previous php.doc.bugs (#17001) next »