php配置文件语法

2013年12月11日 09:21:58

; The syntax of the file is extremely simple.  Whitespace and lines
; beginning with a semicolon are silently ignored (as you probably guessed).
; Section headers (e.g. [Foo]) are also silently ignored, even though
; they might mean something in the future.

php.ini 的语法非常简单,空白和以分号开头的行都会被忽略掉(估计你也这样想),段落标识符也会被忽略,即便这个标识符表达了某种意思

根据上面的说法:

1.(指令)段落的标识符写的时候可以不注意大小写([Xdebuge],[xdebuge])

2.配置命令可以写在配置文件的任何地方

; Directives following the section heading [PATH=/www/mysite] only
; apply to PHP files in the /www/mysite directory.  Directives
; following the section heading [HOST=www.example.com] only apply to
; PHP files served from www.example.com.  Directives set in these
; special sections cannot be overridden by user-defined INI files or
; at runtime. Currently, [PATH=] and [HOST=] sections only work under
; CGI/FastCGI.

有两个段落标识符很特殊,特殊在只能在cgi/fastcgi下起作用:
[PATH=....]

[HOST=....]

path段里的指令集只适用于指定的路径的php脚本文件

host段里的指令集只使用于指定的域名下的php脚本文件

注:Apache可以选择PHP是否工作在fastcgi模式下,nginx下的PHP只能在fastcgi模式下工作

; Directive names are *case sensitive* - foo=bar is different from FOO=bar.

指令的name区分大小写

; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one
; of the INI constants (On, Off, True, False, Yes, No and None) or an expression
; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a
; previously set variable or directive (e.g. ${foo})

指令的value可以是:
字符串,数字,双引号包围的字符串

PHP常量,INI常量

表达式,引用已经定义过的变量或指令

; Boolean flags can be turned on using the values 1, On, True or Yes.
; They can be turned off using the values 0, Off, False or No.

布尔类型的变量

On, True, Yes 会被转化成1;
Off, False, No 会被转化为0;

原文地址:https://www.cnblogs.com/iLoveMyD/p/3468643.html