Yaconf Yaconf::get
(PECL yaconf >= 1.0.0)
Yaconf::get — 항목 검색
설명
public static Yaconf::get(string $name
, mixed $default_value
= NULL): mixed
매개변수
name
- Configuration key, the key looks like "filename.key", or "filename.sectionName,key".
default_value
- 키가 존재하지 않으면 Yaconf::get이 이를 결과로 반환합니다.
반환 값
키가 있으면 구성 결과(문자열 또는 배열)를 반환하고, 없으면 default_value를 반환합니다.
Examples
예제 #1 INI()example
;filenmame foo.ini, placed in directory which is yaconf.directoy [SectionA] ;key value pair key=val ;hash[a]=val hash.a=val ;arr[0]=val arr.0=val ;or arr[]=val ;SectionB inherits SectionA [SectionB:SectionA] ;override configuration key in SectionA key=new_val
위의 예는 다음과 유사한 결과를 출력합니다.
php7 -r 'var_dump(Yaconf::get("foo.SectionA.key"));' //string(3) "val" php7 -r 'var_dump(Yaconf::get("foo.SectionB.key"));' //string(7) "new_val" php7 -r 'var_dump(Yaconf::get("foo")["SectionA"]["hash"]);' //array(1)