parse_ini_file — 解析一个配置文件
说明 ¶
parse_ini_file(string $filename
, bool $process_sections
= false
, int $scanner_mode
= INI_SCANNER_NORMAL
): array|false
parse_ini_file() 载入一个由 filename
指定的 ini 文件,并将其中的设置作为一个关联数组返回。
ini 文件的结构和 php.ini 的相同。
参数 ¶
filename
要解析的 ini 文件的文件名。如果使用相对路径,则优先在相对于当前工作目录的目录中查找文件,如果未找到则在 include_path 中查找文件进行解析。
process_sections
如果将 process_sections
参数设为 true
,将得到多维数组,包括了配置文件中的节名和配置。process_sections
的默认值是 false
。
scanner_mode
可以是 INI_SCANNER_NORMAL
(默认),也可以是 INI_SCANNER_RAW
。如果提供了 INI_SCANNER_RAW
,然后将不会解析选项值。
As of PHP 5.6.1 can also be specified as INI_SCANNER_TYPED
. In this mode boolean, null and integer types are preserved when possible. String values "true"
, "on"
and "yes"
are converted to true
. "false"
, "off"
, "no"
and "none"
are considered false
. "null"
is converted to null
in typed mode. Also, all numeric strings are converted to integer type if it is possible.
ini 文件使用了bool 型的值 ,scanner_model 要使用 INI_SCANNER_TYPED .否则 值为false 解析为“”。