The configuration file (<var>php.ini</var>
) is read when PHP starts. For the server module version of PHP, only in web
Read once when the server starts. For the CGI and CLI versions, it is read on every call. The search path for
<var>php.ini</var>
is as follows (in order):
<var><var>PHPRC</var></var>
Environment variables. Prior to PHP 5.2.0, the order was after the registry keys mentioned below. <em>php.ini</em>
file locations for different versions of PHP. The registry directories will be checked in the following order: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z], [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and [HKEY_LOCAL_MACHINE\SOFTWARE\ PHP\x], where x, y and z refer to the PHP major version number, minor version number and release batch. If there are keys in IniFilePath in any of these directories, the first value will be used as the location of <em>php.ini</em>
(windows only) . (php video tutorial) <var>C:\windows</var>
or <var>C:\winnt</var>
), or -- with-config-file-path The location specified by the compile-time option. If <var>php-SAPI.ini</var>
exists (SAPI is the current SAPI name in use, so the actual file name is <var>php- cli.ini</var>
or <var>php-apache.ini</var>
, etc.), it will be used instead of <var>php.ini</var>
. SAPI
The name can be determined using php_sapi_name().
Note:
The Apache web server will change the directory to the root directory when it starts, which will cause PHP to try to read in the root directory
<var>php.ini</var>
, if present.
Note:
Environment variables can be used in
<var>php.ini</var>
.
The <var>php.ini</var>
directives processed by the extension library are documented on the pages of each extension library. Kernel configuration optionsSee appendix. But maybe not all PHP
The instructions are documented in the manual. For a complete list of configuration directives in your version of PHP, read the <var>php.ini</var>
file, which is commented out. Also, maybe getting the latest <var>php.ini</var>
from Git will help too.
Example #1<var>php.ini</var>
Example
; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"
Since PHP 5.1.0, it is possible to reference an existing .ini in an .ini file Variables. For example: open_basedir = ${open_basedir} ":/new/dir".
The above is the detailed content of What is the php main configuration file. For more information, please follow other related articles on the PHP Chinese website!