Home > Article > Backend Development > What is the php main configuration file
The configuration file (php.ini
) 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
php.ini
is as follows (in order):
PHPRC
Environment variables. Prior to PHP 5.2.0, the order was after the registry keys mentioned below. php.ini
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 php.ini
(windows only) . (php video tutorial) C:\windows
or C:\winnt
), or -- with-config-file-path The location specified by the compile-time option. If php-SAPI.ini
exists (SAPI is the current SAPI name in use, so the actual file name is php- cli.ini
or php-apache.ini
, etc.), it will be used instead of php.ini
. 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
php.ini
, if present.
Note:
Environment variables can be used in
php.ini
.
The php.ini
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 php.ini
file, which is commented out. Also, maybe getting the latest php.ini
from Git will help too.
Example #1php.ini
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!