# 命名空间(Namespaces)

**命名空间与目录**

对于文件来说，目录就扮演了命名空间的角色

**支持**

PHP 5.3.0 开始

**影响**

类，函数和常量

**定义**

* 通过关键字namespace来声明。
* 所有代码之前（只允许declare()语句）
* 允许指定层次化的命名空间的名称
* 必须使用反斜杠 “ \”
* 也可以在同一个文件中定义多个命名空间 &#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://phper.shujuwajue.com/php-gao-ji-te-xing/ming-ming-kong-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
