parse_ini_string

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

parse_ini_string解析配置字符串

說明

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

parse_ini_string() 返回 ini 字符串解析后的關(guān)聯(lián)數(shù)組

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

參數(shù)

ini

ini 字符串內(nèi)容

process_sections

設(shè)置 process_sections 參數(shù)為 true,得到一個多維數(shù)組,包含名稱和設(shè)置。process_sections 默認(rèn)為 false

scanner_mode

可以是 INI_SCANNER_NORMAL (默認(rèn))或 INI_SCANNER_RAW 。如果是 INI_SCANNER_RAW,那么選項(xiàng)值不會被解析。

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.

返回值

執(zhí)行成功返回一個關(guān)聯(lián)數(shù)組,返回 false 為失敗

注釋

注意: 保留關(guān)鍵字不能作為 ini 的鍵,包括 null, yes, no, true, false, on, off, none以及空值,off,no 和錯誤的結(jié)果集,值為 yes 和 正確的結(jié)果集。除非使用 INI_SCANNER_TYPED 模式。 字符 ?{}|&~![()^" 不能在任何地方使用作為鍵和有特殊意義的值。

參見