내장함수 parse_ini_file() 흉내내기
parse_ini_file()함수는 PHP에 내장되어 공식적으로 제공되는 함수로 초기화 파일의 키 정보를 배열 구조로 읽어들일 수 있습니다. 이 함수의 사용법에 대한 것은 php.net에서 제공하는 매뉴얼을 참조하기 바랍니다.
여기서는 이 함수와 동일한 기능을 하는 함수를 INI 핸들러를 이용하여 연습삼아 작성해 보고자 합니다.
[code php;gutter:false]
/**
* PHP4에서 제공되는 내장함수 parse_ini_file과 동일한 역할을 하는 함수임
* 이 함수는 정식으로 지원되지 않는 함수로 향후 버전과의 호환성이 없습니다.
*
* @param string $inifile ini filename
* @param bool $process_sections
* @return array Returns the settings in this function in an associative array.
* By settting the last process_sections parameter to true,
* you get a multidimemsional array,
* with the section names and settings included.
* @access global
*/
function my_parse_ini_file($inifile, $process_sections=false) {
/**
* INI 핸들러 클래스 파일이 있는 경로를 서버 상황에 맞게 수정할 것
*/
include_once("./class/INI/class.hIniHandler.php");
$ini = new hIniHandler(
array(
"active_eval_number" => false,
"active_eval_unit" => false,
"active_eval_path" => false
"active_process_sections" => $process_sections,
)
);
$ini->read($inifile);
return $ini->get();
}
[/code]
직접 실험해 보시면 알겠지만 PHP 내장함수 parse_ini_file() 함수에서 얻은 결과와 INI 핸들러를 이용한 my_parse_ini_file() 함수에서 얻은 결과가 거의 동일하다는 것을 알 수 있을 것입니다. 이에 대한 자세한 내용은 "값의 평가" 메뉴를 참조바랍니다.
'phpsource > 파일분석' 카테고리의 다른 글
{INI 파일}7.업그레이드 및 패치 (0) | 2003.06.25 |
---|---|
{INI 파일}5.값의 평가 (0) | 2003.06.25 |
{INI 파일}4.사용 함수 (0) | 2003.06.25 |
{INI 파일}3.파일 구조 (0) | 2003.06.25 |
{INI 파일}2.INI 핸들러 (0) | 2003.06.25 |