Config_Container::getItem()

Config_Container::getItem() -- 查找指定的条目

大纲

require_once 'Config/Container.php';

mixed Config_Container::getItem ([字符串 $type = NULL [, 字符串 $name = NULL [, mixed $content = NULL [, 数组 $attributes = NULL [, int $index = -1]]]]])

基本描述

该方法根据指定的参数查找对应的条目。

该方法仅用于类型为'section'的对象。 注意:根也被认为是一个节。 该方法不能递归查找,仅能在当前结构中查找。

参数

字符串 $type

条目类型:如directive, section, comment, blank...

字符串 $name

条目名称

mixed $content

被查找条目须包含的内容

数组 $attributes

被查找条目须包含的属性和该属性的值

整型值 $index

被返回的对象列表中条目的索引值。如果未设置该值,则查找返回最后一条符合名称到底条目。

返回值

mixed - 被找到的引用索引或FALSE(未找到时)。

注意

该函数不能被静态调用。

例子

例子 24-1. A few examples on how to find items using getItem()

// will return the last directive found

$directives =& $obj->getItem('directive');

// will return the last directive found with content 'root'

$directives =& $obj->getItem('directive', null, 'root');

// will return the fourth directive with name 'bar'

$directive_bar_4 =& $obj->getItem('directive', 'bar', null, null, 4);

// will return the last section named 'foo'

$section_foo =& $obj->getItem('section', 'foo');

// will return the last section with attribute 'id' set to 'db'

$section_foo =& $obj->getItem('section', 'foo', null, 数组 ('id' => 'db'));