PHP parse_ini_file() 函数
PHP 教程
· 2019-01-25 13:12:08
定义和用法
parse_ini_file() 函数解析一个配置文件(ini 文件),并以数组的形式返回其中的设置。
语法
parse_ini_file(file,process_sections)
参数 | 描述 |
---|---|
file | 必需。规定要检查的 ini 文件。 |
process_sections | 可选。如果设置为 TRUE,则返回一个多维数组,包括了配置文件中每一节的名称和设置。默认是 FALSE。 |
提示和注释
提示:本函数可以用来读取您自己的应用程序的配置文件,与 php.ini 文件没有关系。
注释:有些保留字不能作为 ini 文件中的键名,包括:null、yes、no、true 和 false。字符 {}|&~![()" 也不能用在键名的任何地方。
实例 1
"test.ini" 的内容:
[names] me = Robert you = Peter [urls] first = "http://www.example.com" second = "http://www.w3cschool.cc"
PHP 代码:
<?php print_r(parse_ini_file("test.ini")); ?>
上面的代码将输出:
Array ( [me] => Robert [you] => Peter [first] => http://www.example.com [second] => http://www.w3cschool.cc )
实例 2
"test.ini" 的内容:
[names] me = Robert you = Peter [urls] first = "http://www.example.com" second = "http://www.w3cschool.cc"
PHP 代码(process_sections 设置为 true):
<?php print_r(parse_ini_file("test.ini",true)); ?>
上面的代码将输出:
Array ( [names] => Array ( [me] => Robert [you] => Peter ) [urls] => Array ( [first] => http://www.example.com [second] => http://www.w3cschool.cc ) )
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
HTTP Developer's Handbook
Chris Shiflett / Sams Publishing / 2003-3-29 / USD 39.99
The largest group with an unsatisfied demand for a good book on HTTP is the worldwide group of Web developers. A good book on HTTP can help new and old Web developers alike, as a thorough understandin......一起来看看 《HTTP Developer's Handbook》 这本书的介绍吧!