Book/yaconf-Phpdoc专题
Yaconf
目录
- 简介
- 安装/配置
- 预定义常量
- Yaconf — The Yaconf class
- Yaconf::get — Retrieve a item
- Yaconf::has — Determine if a item exists
简介
Yaconf is a configurations container, it parses INIT files, stores the result in PHP when PHP is started, the result lives with the whole PHP lifecycle.
类摘要
Yaconf
class Yaconf {
/* 方法 */
public <span
class="modifier">static mixed <span
class="methodname">get ( <span
class="type">string $name [, <span
class="methodparam">mixed
$default_value = NULL ] )
public <span
class="modifier">static bool <span
class="methodname">has ( <span
class="type">string $name )
}
Yaconf::get
Retrieve a item
说明
public <span
class="modifier">static mixed <span
class="methodname">Yaconf::get ( <span
class="type">string $name [, <span
class="methodparam">mixed
$default_value = NULL ] )
参数
name
Configuration key, the key looks like "filename.key", or
"filename.sectionName,key".
default_value
if the key doesn't exists, Yaconf::get will return this as result.
返回值
Returns configuration result(string or array) if the key exists, return default_value if not.
范例
示例 #1 INIexample
;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)
Yaconf::has
Determine if a item exists
说明
public <span
class="modifier">static bool <span
class="methodname">Yaconf::has ( <span
class="type">string $name )
参数
name