定义和用法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 = Robertyou = Peter[urls]first = "http://www.example.com"second = "http://www.w3cschool.cc" PHP 代码: <?phpprint_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 = Robertyou = Peter[urls]first = "http://www.example.com"second = "http://www.w3cschool.cc" PHP 代码(process_sections 设置为 true): <?phpprint_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 move_uploaded_file() 函数 PHP pathinfo() 函数 |