Config_Container::createItem()
Config_Container::createItem() -- 创建一个节条目的子节条目
大纲
require_once 'Config/Container.php'; |
对象 &Config_Container::createItem (字符串 $type, mixed $item, 字符串 $content [, 数组 $attributes = NULL [, 字符串 $where = 'bottom' [, 对象 $target = NULL]]])
基本描述
该方法必须在一个已有节内调用,所创建的子条目可以是任意值。
它将为当前条目增加一个新的子条目。如果指定了位置,那么新条目将被创建在该指定位置。推荐使用辅助方法来实现这个功能,而不是直接使用该方法。
参数
- 字符串
$type
-
新条目的类型:如directive,
section, comment,
blank...
- 混合的 $item
-
条目名称
- 字符串
$content
-
条目内容
- 数组
$attributes
-
条目属性
- 字符串
$where
-
创建条目的位置'bottom',
'top', 'after',
'before'
- 对象
$target
仅当$where参数使用'before'或'after'时使用。
Throws
表 24-1. 可能出现的 PEAR_Error 值
| Error code | Error value | Meaning | Solution |
|---|
| | "" | | |
例子
例子 24-1. Create some new items using createItem() $section =& new Config_Container('section', 'conf');
$section->createItem('directive', 'user', 'root');
$section->createItem('directive', 'pass', 'root');
$header =& $section->createItem('comment', null, 'Database Configuration', 'top');
$section->createItem('blank', null, null, 'after', $header); |
|