配置文件(php.ini)在 PHP 启动时被读取。对于服务器模块版本的 PHP,仅在 web 服务器启动时读取一次。对于CGI和CLI版本,每次调用都会读取。
php.ini的搜索路径如下(按顺序):
如果存在php-SAPI.ini(SAPI 是当前所用的 SAPI名称,因此实际文件名为php-cli.ini或php-apache.ini等),则会用它替代php.ini。SAPI 的名称可以用 php_sapi_name() 来测定。
Note:Apache web 服务器在启动时会把目录转到根目录,这将导致 PHP 尝试在根目录下读取php.ini,如果存在的话。
Note:
在php.ini中可以使用环境变量。
由扩展库处理的php.ini指令,其文档分别在各扩展库的页面。内核配置选项见附录。不过也许不是所有的 PHP 指令都在手册中有文档说明。要得到自己的 PHP 版本中的配置指令完整列表,请阅读php.ini文件,其中都有注释。此外,也许从 Git 得到的最新版php.ini 也有帮助。
Example #1php.ini例子
; 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"
自 PHP 5.1.0 起,有可能在 .ini 文件内引用已存在的 .ini 变量。例如:open_basedir = ${open_basedir} ":/new/dir"。
以上就是php主配置文件是什么的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号