Home > Backend Development > PHP Problem > What is the php main configuration file

What is the php main configuration file

步履不停
Release: 2023-02-23 07:28:02
Original
4412 people have browsed it

What is the php main configuration file

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

  • 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) .
  • <var><var>PHPRC</var></var>Environment 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 <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)
  • [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 (<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"
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template