PHP의 parse_ini_file () 함수
정의 및 사용
parse_ini_file () 함수는 구성 파일 (ini 파일)을 파싱하고, 배열의 설정을 반환한다.
문법
parse_ini_file(file,process_sections)
参数 | 描述 |
---|---|
file | 必需。规定要检查的 ini 文件。 |
process_sections | 可选。如果设置为 TRUE,则返回一个多维数组,包括了配置文件中每一节的名称和设置。默认是 FALSE。 |
팁과주의 사항
팁 :이 기능은 사용자의 응용 프로그램의 구성 파일을 읽을 수 있습니다, 아무것도 php.ini 파일과 함께 할 수 없습니다.
참고 : 어떤 단어가 ini 파일 키로 유지 될 수 없다 포함 : 널 (null), 예, 아니오, 참과 거짓을.문자 {} |! & ~ () "도 아니다 키 이름의 [어떤 장소 수 있습니다.
예 1
"Test.ini"내용 :
[names]
me = Robert
you = Peter
[urls]
first = "http://www.example.com"
second = "http://www.w3cschool.cc"
me = Robert
you = Peter
[urls]
first = "http://www.example.com"
second = "http://www.w3cschool.cc"
PHP 코드 :
<?php
print_r(parse_ini_file("test.ini"));
?>
print_r(parse_ini_file("test.ini"));
?>
가 출력 위의 코드 :
Array
(
[me] => Robert
[you] => Peter
[first] => http://www.example.com
[second] => http://www.w3cschool.cc
)
(
[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"
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));
?>
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
)
)
(
[names] => Array
(
[me] => Robert
[you] => Peter
)
[urls] => Array
(
[first] => http://www.example.com
[second] => http://www.w3cschool.cc
)
)
PHP 파일 시스템 참조 설명서를 완료