Config_Container::getItem()

Config_Container::getItem() -- 特定の項目の発見を試みる

概要

require_once 'Config/Container.php';

mixed Config_Container::getItem ([string $type = NULL [, string $name = NULL [, mixed $content = NULL [, array $attributes = NULL [, int $index = -1]]]]])

説明

このメソッドはは、 指定されたパラメーターに応答する項目を発見しようとします。

このメソッドは、 タイプ'section' のオブジェクトでのみ呼ぶことができます。 ルートががセクションであることに注意してください。 このメソッドは、再帰的でなく現在の構造を維持しようとします。

パラメータ

string $type

項目の種類です。(directive, section, comment, blank...)

string $name

項目名です。

mixed $content

この内容を持つ項目を発見します。

array $attributes

任意の値への属性セットを持つ項目を発見します。

integer $index

返されたオブジェクトリスト内の項目のインデックスです。 それがセットされない場合、 この名前を持つ最後の項目を返すでしょう。

返り値

mixed - 発見した項目のリファレンスか、見つからない場合はFALSEを返します。

注意

この関数は、スタティックにコールする ことはできません。

例 31-1getItem()を使用して、項目を見つける方法上の少数の例


<?php
// 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, array('id' => 'db'));
?>