PHP parse_ini_file 解析配置文件

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  解析为“”。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

larance

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值