Changeable
文档「List of php.ini directives」列出了PHP.INI中的指令。
而「Changeable」列显示了「模式」,该「模式」决定了「在什么时候」和「在什么位置」可以设置指令。下面是简短的介绍:
模式 | 含义 |
---|---|
PHP_INI_USER | 可以在:(1)用户脚本(比如使用ini_set()函数);(2)Windows注册表;(3)从PHP 5.3开始的.user.ini文件; |
PHP_INI_PERDIR | 可以在:php.ini;htaccess;httpd.conf;.user.ini; |
PHP_INI_SYSTEM | 可以在:php.ini;htaccess;httpd.conf; |
PHP_INI_ALL | 可以在:任何地方; |
有关「模式」定义,请参阅「Changeable mode values」部分。
配置文件的加载路径
The configuration file (php.ini) is read when PHP starts up.
For the server module versions of PHP, this happens only once when the web server is started.
For the CGI and CLI versions, it happens on every invocation.
采集自源码目录下的php.ini-production文件
- SAPI module specific location.
- The PHPRC environment variable. (As of PHP 5.2.0)
- A number of predefined registry keys on Windows (As of PHP 5.2.0)
- Current working directory (except CLI)
- The web server’s directory (for SAPI modules), or directory of PHP (otherwise in Windows)
- The directory from the –with-config-file-path compile time option, or the Windows directory (C:\windows or C:\winnt)
采集自官网
http://php.net/manual/en/configuration.file.php
1.SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
2.The PHPRC environment variable. Before PHP 5.2.0, this was checked after the registry key mentioned below.
3.(Windows)As of PHP 5.2.0, the location of the php.ini file can be set for different versions of PHP. The following registry keys are examined in order:
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x],
where x, y and z mean the PHP major, minor and release versions.
If there is a value for IniFilePath in any of these keys, the first one found will be used as the location of the php.ini (Windows only).
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only).
4.Current working directory (except CLI).
5.The web server’s directory (for SAPI modules), or directory of PHP (otherwise in Windows).
6.Windows directory (C:\windows or C:\winnt) (for Windows), or –with-config-file-path compile time option.
注释及无效的行
以 `;’ 开始的行;
空白行;
章节头,如:[Foo];
指令章节及作用域名
http://php.net/ini.sections
跟在章节头 [PATH=/www/mysite],后的指令只作用于 /www/mysite 文件夹;
跟在章节头 [HOST=www.exm.com],后的指令只作用于 www.exm.com 的主机;
这些章节不能被 “用户定义的INI” 或者 “运行时” 重写;
当前 [HOST][PATH],只作用于,CGI/FASTCGI;
注意事项
指令是用于配置PHP,包含扩展的配置;
指令名:大小写敏感;并且不做校验,意思就是说不检查一个指令名是否有效;
如果指令配置错误,就采用默认值;
扩展模块的查找路径
通过 extension_dir=”” 指定,默认路径为 install_path/lib/php/extensions/no-debug-non-zts-xxxxxx/
如果引入扩展时只指定了扩展名 extension=”demo.so”,会从默认路径查找; 也可以使用绝对路径( extension=”/path/to/demo.so”);
相关链接
List of php.ini directives
List of php.ini sections
Description of core php.ini directives
参考文献
What is PHP_INI_PERDIR and PHP_INI_USER in .user.ini file?