Home  >  Article  >  Backend Development  >  What is the php main configuration file

What is the php main configuration file

步履不停
步履不停Original
2019-06-11 17:41:184210browse

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):

  • The location specified by the SAPI module (in Apache 2 PHPIniDir directive, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD) .
  • PHPRCEnvironment variables. Prior to PHP 5.2.0, the order was after the registry keys mentioned below.
  • Since PHP 5.2.0, you can specify different 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)
  • [HKEY_LOCAL_MACHINE\SOFTWARE\PHP] The value of IniFilePath (Windows registry location).
  • Current working directory (for CLI).
  • The web server directory (for SAPI modules) or the directory where PHP is located (other cases under Windows).
  • Windows directory (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 directoryphp.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.iniExample

; 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn