parse_ini_string

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

parse_ini_string解析配置字符串

说明

parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false

parse_ini_string() 返回 ini_string 字符串解析后的关联数组。

ini 字符串的格式参考 php.ini

参数

ini_string

ini 字符串内容。

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.

返回值

执行成功返回一个关联数组,返回 false 为失败。

注释

注意: 有些保留字不能作为 ini 文件中的键名,包括:nullyesnotruefalseonoffnone。除非使用 INI_SCANNER_TYPED 模式,否则 nulloffnofalse 的值等效于 ""onyestrue 的值等效于 "1"。字符 ?{}|&~![()^" 也不能用在键名的任何地方,而且这些字符在选项值中有着特殊的意义。

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top