> For the complete documentation index, see [llms.txt](https://phper.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://phper.shujuwajue.com/phpxuan-xiang-he-yun-xing-yuan-li/phppei-zhi-xuan-xiang.md).

# PHP配置选项

**PHP选项之“display\_errors”**

该选项设置是否将错误信息作为输出的一部分显示到屏幕，或者对用户隐藏而不显示。

设置 "stderr" 表示发送到 stderr 而不是 stdout。 "stderr"从 PHP 5.2.4 开始可用。在以前的版本中，该配置值的类型为 boolean.

这是一个辅助开发的功能，建议永远不要在生产系统中使用 (例如系统被连接到互联网对外提供服务)。

尽管 display\_errors 也可以在运行时设置 (使用 ini\_set())， 但是脚本出现致命错误时任何运行时的设置都是无效的。 因为在这种情况下预期运行的操作不会被执行。

```php
// 开发时
error_reporting(E_ALL);
ini_set('display_errors', true);
```

**PHP选项之“error\_reporting”**

设置错误报告的级别。该参数可以是一个任意的表示二进制位字段的整数，或者常数名称。错误级别和常数是在 预定义常量定义的，在 php.ini 之中也有专门的说明。

可以通过 error\_reporting() 函数进行设置。

在PHP 4和PHP 5之中，其默认值为 E\_ALL & \~E\_NOTICE。 该设置表示除了 E\_NOTICE 其他都显示的错误级别。在开发过程中很有必要显示它们。

**PHP选项之“magic\_quotes\_gpc”**

本特性已自 PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除。

为 GPC (Get/Post/Cookie) 操作设置 magic\_quotes 状态。 当 magic\_quotes 为 on，所有的 ' (单引号)、" (双引号)、\（反斜杠）和 NUL's 被一个反斜杠自动转义。

**PHP选项之“magic\_quotes\_runtime”**

本特性已自 PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除。

如果启用了 magic\_quotes\_runtime，大多数返回任何形式外部数据的函数，包括数据库和文本段将会用反斜线转义引号。 如果启用了 magic\_quotes\_sybase，单引号会被单引号转义而不是反斜线。

受 magic\_quotes\_runtime 影响的函数（不包括 PECL 里的函数）： file\_get\_contents()、file()、fgets()、fwrite()、fread()

**PHP选项之“variables\_order”**

设置EGPCS (Environment, Get, Post, Cookie, and Server)超全局变量解析的顺序。例如，如果这个选项被设置为 “SP” ，那么PHP将创建 超级全局变量 $\_SERVER 、 $\_POST, 但是不会创建 $\_ENV, $\_GET, 和 $\_COOKIE。设置为空表示不创建任何超全局变量。

**PHP选项之“request\_order”**

确定$\_GET和$\_POST的等超全局变量的顺序，后面的会把前面的数据重写覆盖。

例如： request\_order = "GP“

如果post请求同时有get的参数，那么post的数据会把get的参数覆盖。

**PHP选项之“safe\_mode”**

PHP 的安全模式是为了试图解决共享服务器（shared-server）安全问题而设立的。在结构上，试图在 PHP 层上解决这个问题是不合理的，但修改 web 服务器层和操作系统层显得非常不现实。因此许多人，特别是 ISP，目前使用安全模式。

本特性已自 PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除。

**PHP选项之“open\_basedir”**

将 PHP 所能打开的文件限制在指定的目录树，包括文件本身。本指令不受安全模式打开或者关闭的影响。

当一个脚本试图用例如 fopen() 或者 gzopen() 打开一个文件时，该文件的位置将被检查。当文件在指定的目录树之外时 PHP 将拒绝打开它。所有的符号连接都会被解析，所以不可能通过符号连接来避开此限制。

**PHP选项之“disable\_classes 、disable\_functions**”

“disable\_classes”指令可以使你出于安全的理由禁用某些类。用逗号分隔类名。disable\_classes 不受安全模式的影响。

“disable\_functions”指令允许你基于安全原因禁止某些函数。接受逗号分隔的函数名列表作为参数。 disable\_functions 不受安全模式的影响。

**PHP选项之“ expose\_php ”**

“决定是否暴露 PHP 被安装在服务器上（例如在 Web 服务器的信息头中加上其签名：X-Powered-By: PHP/5.3.7)。

可以通过这个设置这个为off 关闭掉。

这个参数的默认值是开启的。

**PHP选项之“max\_input\_time 、max\_execution\_time”**

“max\_input\_time ：脚本解析输入数据（类似 POST 和 GET）允许的最大时间，单位是秒。 它从接收所有数据到开始执行脚本进行测量的。

max\_execution\_time 这设置了脚本被解析器中止之前允许的最大执行时间，单位秒。 这有助于防止写得不好的脚本占尽服务器资源。 默认设置为 30。 从命令行运行 PHP 时，默认设置为 0。

**PHP选项之“memory\_limit ”**

系统分配给PHP的最大内存数量。

可以在PHP代码中动态的修改，int\_set(‘memory\_limit’,’128M’);

如果设置为“-1” ，表示不限制大小，以实际系统的内存为依据。

**PHP选项之“register\_globals”**

是否把超级全局变量 EGPCS (Environment, GET, POST, Cookie, Server) 里面的数据创建为全局变量。

本特性已自 PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除。

**PHP选项之“include\_path”**

在设置的路径中寻找文件。它会检查第一个路径，如果它没有找到它，检查下一个路径，直到它找到的包含文件或警告或错误回报。您可以使用set\_include\_path（）在运行时修改或设定你的include路径。

Linux的路径用冒号分割

```
include_path=".:/php/includes"
```

Windows下的路径用分号分割

```
include_path=".;c:\php\includes"
```

**PHP选项之“extension\_dir”**

PHP动态连接扩展库存放的目录，在Linux下，扩展后缀一般”.so”,在Windows下一般都是“.dll”

![](/files/-LfnTHnOx4vEtdIBKFKs)

**PHP选项之“upload\_tmp\_dir”相关upload\_tmp\_dir**

* upload\_max\_filesize = 2M
* file\_uploads = On
* max\_file\_uploads = 20
* post\_max\_size = 8M

**PHP选项之“default\_socket\_timeout ”相关**

基于 socket 的流的默认超时时间（秒），默认60秒。

![](/files/-LfnTHnZ3-Bmf4BwSWrE)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://phper.shujuwajue.com/phpxuan-xiang-he-yun-xing-yuan-li/phppei-zhi-xuan-xiang.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
