parse_ini_string
(PHP 5 >= 5.3.0, PHP 7)
parse_ini_string — 解析配置字符串
说明
$ini
[, bool $process_sections = false
[, int $scanner_mode = INI_SCANNER_NORMAL
]] ) : array
parse_ini_string() 返回 ini 字符串解析后的关联数组
ini 字符串的格式参考 php.ini
参数
-
ini -
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 toTRUE. "false", "off", "no" and "none" are consideredFALSE. "null" is converted toNULLin typed mode. Also, all numeric strings are converted to integer type if it is possible.
返回值
执行成功返回一个关联数组,返回 FALSE 为失败
注释
Note: 保留关键字不能作为 ini 的键,包括 null, yes, no, true, false, on, off, none以及空值,off,no 和错误的结果集,值为 yes 和 正确的结果集。除非使用
INI_SCANNER_TYPED模式。 字符 ?{}|&~![()^" 不能在任何地方使用作为键和有特殊意义的值。