## 语言选项

short_open_tag "1" PHP_INI_PERDIR
precision "14" PHP_INI_ALL
serialize_precision "-1" PHP_INI_ALL 在 PHP 7.1.0 以前，默认值为 17。
disable_functions "" 仅为 PHP_INI_SYSTEM
disable_classes "" 仅为 php.ini
exit_on_timeout "" PHP_INI_ALL
expose_php "1" 仅为 php.ini
hard_timeout "2" PHP_INI_SYSTEM 从 PHP 7.1.0 起可用
zend.exception_ignore_args "0" PHP_INI_ALL 从 PHP 7.4.0 起可用
zend.multibyte "0" PHP_INI_ALL
zend.script_encoding NULL PHP_INI_ALL
zend.detect_unicode NULL PHP_INI_ALL
zend.signal_check "0" PHP_INI_SYSTEM
zend.assertions "1" 有限制的 PHP_INI_ALL
zend.exception_string_param_max_len "15" PHP_INI_ALL 自 PHP 8.0.0 起可用。

short_open_tag bool

precision int

serialize_precision int

expose_php bool

disable_functions string

disable_classes string

zend.assertions int

zend.exception_string_param_max_len int

hard_timeout int

Fatal error: Maximum execution time of 30+2 seconds exceeded (terminated) in Unknown on line 0


zend.exception_ignore_args bool

zend.multibyte bool

zend.script_encoding string

zend.detect_unicode bool

zend.signal_check bool

exit_on_timeout bool

## 资源限制

memory_limit "128M" PHP_INI_ALL

memory_limit int

## 性能调整

realpath_cache_size "4M" PHP_INI_SYSTEM PPHP 7.0.16 和 7.1.2 之前，默认值为 "16K"
realpath_cache_ttl "120" PHP_INI_SYSTEM

realpath_cache_size int

realpath_cache_ttl int

## 数据处理

arg_separator.output "&" PHP_INI_ALL
arg_separator.input "&" PHP_INI_PERDIR
variables_order "EGPCS" PHP_INI_PERDIR
request_order "" PHP_INI_PERDIR
auto_globals_jit "1" PHP_INI_PERDIR
register_argc_argv "1" PHP_INI_PERDIR
post_max_size "8M" PHP_INI_PERDIR
auto_prepend_file NULL PHP_INI_PERDIR
auto_append_file NULL PHP_INI_PERDIR
default_mimetype "text/html" PHP_INI_ALL
default_charset "UTF-8" PHP_INI_ALL
input_encoding "" PHP_INI_ALL
output_encoding "" PHP_INI_ALL
internal_encoding "" PHP_INI_ALL

arg_separator.output string

arg_separator.input string

PHP 用于将输入的 URL 解析为变量的分隔符列表。

variables_order string

$_REQUEST 的内容和顺序也受到此指令的影响。 request_order string 该指令描述了 PHP 将 GET、POST 和 Cookie 变量注册到 _REQUEST 数组中的顺序。注册是从左到右完成的，新值覆盖旧值。 如果未设置此指令，则 variables_order 用于$_REQUEST 内容。

auto_globals_jit bool

register_argc_argv bool

enable_post_data_reading bool

post_max_size int

PHP 允许使用字节值的快捷方式，包括 K（千）、M（兆）和 G（千兆）。如果使用其中任何一个，PHP 将自动进行转换。注意不要超过 32 位有符号整数限制（如果使用的是 32 位版本），因为这会导致脚本失败。

post_max_size 变更日志

5.3.4 post_max_size = 0 will not disable the limit when the content type is application/x-www-form-urlencoded or is not registered with PHP.
5.3.2 , 5.2.12 Allow unlimited post size by setting post_max_size to 0.

auto_prepend_file string

auto_append_file string

default_mimetype string

PHP 内置默认媒体类型设置为 text/html。

default_charset string

“UTF-8”是默认值，如果省略 encoding 参数，它的值将用作 htmlentities()html_entity_decode()htmlspecialchars() 的默认字符编码。 如果未设置 iconv.input_encodingiconv.output_encodingiconv.internal_encoding 配置选项，则 default_charset 的值也将用于设置 iconv 函数的默认字符集，如果 mbstring.http_input mbstring.http_output mbstring.internal_encoding 配置选项未设置，则也可用于 mbstring 函数。

input_encoding string

output_encoding string

internal_encoding string

## 路径和目录

include_path ".;/path/to/php/pear" PHP_INI_ALL
open_basedir NULL PHP_INI_ALL
doc_root NULL PHP_INI_SYSTEM
user_dir NULL PHP_INI_SYSTEM
user_ini.cache_ttl "300" PHP_INI_SYSTEM
user_ini.filename ".user.ini" PHP_INI_SYSTEM
extension_dir "/path/to/php" PHP_INI_SYSTEM
extension NULL php.ini only
zend_extension NULL php.ini only
cgi.check_shebang_line "1" PHP_INI_SYSTEM
cgi.fix_pathinfo "1" PHP_INI_SYSTEM
cgi.force_redirect "1" PHP_INI_SYSTEM
cgi.nph "0" PHP_INI_SYSTEM
cgi.redirect_status_env NULL PHP_INI_SYSTEM
fastcgi.impersonate "0" PHP_INI_SYSTEM
fastcgi.logging "1" PHP_INI_SYSTEM

include_path string

PHP considers each entry in the include path separately when looking for files to include. It will check the first path, and if it doesn't find it, check the next path, until it either locates the included file or returns with an E_WARNING or an E_ERROR. You may modify or set your include path at runtime using set_include_path().

include_path=".:/php/includes"

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

Using a . in the include path allows for relative includes as it means the current directory. However, it is more efficient to explicitly use include './file' than having PHP always check the current directory for every include.

ENV variables are also accessible in .ini files. As such it is possible to reference the home directory using ${LOGIN} and ${USER}.

Environment variables may vary between Server APIs as those environments may be different.

open_basedir string

Limit the files that can be accessed by PHP to the specified directory-tree, including the file itself.

When a script tries to access the filesystem, for example using include, or fopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to access it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) open_basedir.

open_basedir can affect more than just filesystem functions; for example if MySQL is configured to use mysqlnd drivers, LOAD DATA INFILE will be affected by open_basedir. Much of the extended functionality of PHP uses open_basedir in this way.

The special value . indicates that the working directory of the script will be used as the base-directory. This is, however, a little dangerous as the working directory of the script can easily be changed with chdir().

In httpd.conf, open_basedir can be turned off (e.g. for some virtual hosts) the same way as any other configuration directive with "php_admin_value open_basedir none".

Under Windows, separate the directories with a semicolon. On all other systems, separate the directories with a colon. As an Apache module, open_basedir paths from parent directories are now automatically inherited.

The restriction specified with open_basedir is a directory name, not a prefix.

The default is to allow all files to be opened.

open_basedir can be tightened at run-time. This means that if open_basedir is set to /www/ in php.ini a script can tighten the configuration to /www/tmp/ at run-time with ini_set(). When listing several directories, you can use the PATH_SEPARATOR constant as a separator regardless of the operating system.

Using open_basedir will set realpath_cache_size to 0 and thus disable the realpath cache.

open_basedir 只是额外的安全保障，并不全面，因此在需要安全性时并不能依赖它。

doc_root string

PHP's "root directory" on the server. Only used if non-empty. If PHP was not compiled with FORCE_REDIRECT, you should set doc_root if you are running PHP as a CGI under any web server (other than IIS). The alternative is to use the cgi.force_redirect configuration below.

user_ini.cache_ttl int

user_ini.filename string

user_dir string

The base name of the directory used on a user's home directory for PHP files, for example public_html .

extension_dir string

PHP 寻找可动态加载扩展的目录。建议指定绝对路径。参阅 enable_dldl()

extension string

zend_extension string

Name of dynamically loadable Zend extension (for example XDebug) to load when PHP starts up.

cgi.check_shebang_line bool

Controls whether CGI PHP checks for line starting with #! (shebang) at the top of the running script. This line might be needed if the script support running both as stand-alone script and via PHP CGI. PHP in CGI mode skips this line and ignores its content if this directive is turned on.

cgi.discard_path bool

If this is enabled, the PHP CGI binary can safely be placed outside of the web tree and people will not be able to circumvent .htaccess security.

cgi.fix_pathinfo bool

Provides real PATH_INFO/ PATH_TRANSLATED support for CGI. PHP's previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok what  PATH_INFO is. For more information on PATH_INFO, see the CGI specs. Setting this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting of zero causes PHP to behave as before. It is turned on by default. You should fix your scripts to use SCRIPT_FILENAME rather than PATH_TRANSLATED.

cgi.force_redirect bool

cgi.force_redirect is necessary to provide security running PHP as a CGI under most web servers. Left undefined, PHP turns this on by default. You can turn it off at your own risk.

Windows Users: When using IIS this option must be turned off. For OmniHTTPD or Xitami the same applies.

cgi.nph bool

If cgi.nph is enabled it will force cgi to always sent Status: 200 with every request.

cgi.redirect_status_env string

If cgi.force_redirect is turned on, and you are not running under Apache or Netscape (iPlanet) web servers, you may need to set an environment variable name that PHP will look for to know it is OK to continue execution.

Setting this variable may cause security issues, know what you are doing first.

cgi.rfc2616_headers int

Tells PHP what type of headers to use when sending HTTP response code. If it's set to 0, PHP sends a » RFC 3875 "Status:" header that is supported by Apache and other web servers. When this option is set to 1, PHP will send » RFC 2616 compliant headers.

If this option is enabled, and you are running PHP in a CGI environment (e.g. PHP-FPM) you should not use standard RFC 2616 style HTTP status response headers, you should instead use their RFC 3875 equivalent e.g. instead of header("HTTP/1.0 404 Not found"); you should use header("Status: 404 Not Found");

Leave it set to 0 unless you know what you're doing.

fastcgi.impersonate string

FastCGI under IIS (on WINNT based OS) supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under. mod_fastcgi under Apache does not currently support this feature (03/17/2002) Set to 1 if running under IIS. Default is zero.

fastcgi.logging bool

Turns on SAPI logging when using FastCGI. Default is to enable logging.

## 文件上传

max_input_nesting_level 64 PHP_INI_PERDIR
max_input_vars 1000 PHP_INI_PERDIR

file_uploads bool

upload_tmp_dir string

upload_max_filesize int

post_max_size 必须大于此值。

max_file_uploads int

## 常规 SQL

sql.safe_mode "0" PHP_INI_SYSTEM 自 PHP 7.2.0 起移除

sql.safe_mode bool

If turned on, database connection functions that specify default values will use those values in place of any user-supplied arguments. For details on the default values, see the documentation for the relevant connection functions.

## Windows 专用

Windows 专用配置选项

windows.show_crt_warning "0" PHP_INI_ALL

windows.show_crt_warning bool

### User Contributed Notes 20 notes

andre dot wetter at myelco dot ch
1 year ago
 If you use Microsoft IIS Windows and want to use open_basedir restrictions with multiple dirs you have to set them into single quotes in the main config xml file of IIS (C:\Windows\System32\inetsrv\config\applicationHost.config). Works fine in IIS 10.Multiple files with single quotes and ; for windows:"C:\php\php-cgi.exe|-d open_basedir='C:\Windows\Temp\;D:\mywebsite1\'"Only one dir works fine without single quotes:"C:\php\php-cgi.exe|-d open_basedir=D:\mywebsite1\"In my main config xml file of IIS there are 2 nodes to set per website and the definitions have to be equal:configuration\Location\system.webServer\handlers\addconfiguration\system.webServer\fastCgi 
21
csg at DEL_THISdiatom dot de
17 years ago
 Starting with PHP 4.4.0 (at least PHP version 4.3.10 did have old, documented behaviour) interpretation of value of "session.save_path" did change in conjunction with "save_mode" and "open_basedir" enabled.Documented ( http://de.php.net/manual/en/ref.session.php#ini.session.save-path ):  Values of "session.save_path" should or may be  **without**  ending slash.  For instance:<?php  // Valid only  *before* PHP 4.4.0:  ini_set( "session.save_path", "/var/httpd/kunde/phptmp" );?> will mean:  The directory "/var/httpd/kunde/phptmp/" will be used to write data and therefore must be writable by the web server.Starting with PHP 4.4.0 the server complains that "/var/httpd/kunde/" is not writable.Solution: Add an ending slash in call of ini_set (or probably whereever you set "session.save_path"), e.g.:<?php  // Note the slash on ".....phptmp/":  ini_set( "session.save_path", "/var/httpd/kunde/phptmp/" );?>Hope, that does help someone. 
Simone Pellegatta
2 years ago
 Be careful while using auto_prepend_file.When the custom exception handler, set by set_exception_handler(), handles an uncaught exception, it interrupts the execution of every script.If the script with the unhandled exception has been automatically prepended or included by an automatically prepended script, however, the main script will continue running anyway.This could cause several issues: when we think that throwing an exception would automatically interrupt the current application, a whole chunk of code is going to run anyway. 
luisdev
3 years ago
 https://haydenjames.io/understanding-php-memory_limit/ explains the memory_limit setting nicely. 
Anton Bannikov
2 years ago
 I had a problem with 'open_basedir =' string in php.ini. This string was writtren in VirtualHost Directory directive of Apache2 and successfully rewrote the same php.ini setting! It happened with VestaCP, but I think, it's a common way. Goog luck! 
rlammers at linuxmail dot org
12 years ago
 This is a possible solution for a problem which seems to be a php-ini-problem but is not.If a $_POST is used with large fields e.g. textarea's with more than 120kb characters php returns a blank screen, even if the max_post_size is 8M.This problem may be caused by an apache-module SecFilter.Adding the following lines to the .htaccess solves the problem.SecFilterEngine OffSecFilterScanPOST OffI know this is not a php-issue, but i'm still posting it here since it looks like it is a php-problem and I did not find any sites or forums offering this solution.  -1 amolitor at molitor-design dot com 13 years ago  Amusingly, the include_path logically includes the current directory of the running file as the last entry all the time anyways, so part of the business about shoving "." into the include_path is spurious -- it's "there" on the end all the time, at least in the 5.2.12 source (see main/fopen_wrappers.c around line 503).This one had me goin' for a while.  -2 dougal at gunters dot org 7 years ago  It appears that if you use both the 'include_path' directives and 'open_basedir', that file searches will hit the include path *first*, before local files. But if 'open_basedir' is not in use, then local files are found first. For example, suppose you have code in '/var/www/myfile.php' which does:<?php require_once('config.php');?>Further, assume that there is a local file '/var/www/config.php', and there is also a file '/var/local/php/config.php'.Next, if your php.ini has: include_path = /var/local/php/Normally, this would look for '/var/www/config.php' first, and if not found, then it would try '/var/local/php/config.php'.But if you also have this in php.ini: open_basedir = /var/www/:/var/local/php/Then the require would reverse the order of the search, and load '/var/local/php/config.php', even when the local 'config.php' file exists.Furthermore, if include_path contains directories not in open_basedir, you can end up with a fatal error. For example, change the directive to: open_basedir = /var/www/:/var/local/includes/php/Now the require will first find '/var/local/php/config.php' from the include_path, try to include it, but be unable to because of the open_basedir restrictions.  -2 fernandobasso dot br at gmail dot com 6 years ago  This might help in case someone happens to maintain old applications with a charset other than utf-8.According to the docs, you can override the default charset if you use header().Suppose php.ini sets the default_charset to "UTF-8", but you need a legacy charset, like ISO-8859-1.Still,<?php header('Content-Type: text/html; Charset=ISO-8859-1'); ?>would not override the charset, just add it as well and the resultwas a response header like (note the two charsets): Content-Type:"text/html; Charset=ISO-8859-1;charset=UTF-8"I found it strange the default one as charset with a lowercase cas opposed to my custom charset with an uppercase C.What solved was to _override_ the charset using all lowercase lettersas well for the word “charset”:<?php header('content-type: text/html; charset=ISO-8859-1'); ?>Then, the double charset from the response headers disappeared, and only the single, custom charset remained.  -2 leo at korfu dot cz 16 years ago  "If the size of post data is greater than post_max_size..."It seems that a more elegant way is comparison between post_max_size and$_SERVER['CONTENT_LENGTH']. Please note that the latter includes not only size of uploaded file plus post data but also multipart sequences. Leo 
-3
mrok at mrok dot com
14 years ago
 Note that on some Unix systems (i.e. PHP 5.1.6 on Centos 5.2) include_path in php.ini should NOT be quoted.For example, instead of include_path='.:/usr/share/php'use include_path=.:/usr/share/phpUsing quotes does not cause any error message, but all of your require_once() directives will fail (indicating that file could not be opened) - unless full path to target file is provided. 
-5
txyoji at yahoo dot com
9 years ago
 If you enable "open_basedir" option, it will disable the realpath_cache. This can be a significant performance hit.https://bugs.php.net/bug.php?id=53263 
-5
AntonioK
12 years ago
 Note that there is no way to disable eval() work by using disable_functions directive, because eval() is a language construct and not a function.Many people advise to disable such potentially-insecure functions like system(), exec(), passthru(), eval() and so on in php.ini when not running in safe mode, but eval() would still work even it listed in disable_functions. 
-3
4 years ago
 add enctype="multipart/form-data" to your <form> tag or it will not upload any file even if file_uploads=onex:<form method="POST" action="upload. php" enctype="multipart/form-data">// form contents</form> 
-6
iko at vision dot sk
10 years ago
 auto_globals_jit setting is also affecting \$_REQUEST superglobal in 5.3 It is not explicitly stated in documentation. 
-4
diamondeagle at webmail dot co dot za
3 years ago
 Note regarding the upload_tmp_dir setting and UNC Paths:When using PHP on Windows OS and IIS FastCGI, if you need to use a UNC path to a folder on a network drive for the upload_tmp_dir setting then you must use three \ characters at the front of the UNC path. Windows and PHP use the first slash as an escape character, so if you only use two slashes then it passes a UNC path with just one backslash. That is not valid for UNC paths and you many experience problems when uploading files, such as errors saying that "PHP is missing a temporary folder".Correct:upload_tmp_dir = "\\\path\to\your\folder"Incorrect:upload_tmp_dir = "\\path\to\your\folder" 
-9
kghbln
11 years ago
 Adding multiple directories to open_basedir:open_basedir = "/var/www/htdocs/:/var/www/tmp/" adds both paths /var/www/htdocs/ and /var/www/tmp/. Do not forget the trailing slash, otherwise the last directory will be considered as a prefix (< 5.3.4).On Windows you use ; as the seperator. 
-11
 Remember that open_basedir restriction does not affect exec functions. As long as you do not disable exec functions (see disable_functions, users will be able to use exec("/bin/cat [...]") to access sensitive world readable files. 
 the ini-setting "detect_unicode" is indeed "zend.detect_unicode" (according to the phpinfo of my 5.4.4) 
 Please illuminate this:memory_limit=128mb meaning which?1-per script only then if in a moment 1000 user request php script maximum only 128mb of server ram use6 by script.2-per script + per user if in a moment 1000 user request a php script about 1000*128mb=128gb ram use by script.Thanks