本文整理汇总了PHP中Element::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::set方法的具体用法?PHP Element::set怎么用?PHP Element::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUn_set
/**
* @covers Element::un_set
*/
public function testUn_set()
{
$key = "src";
$value = "img/logo.pgn";
$result = $this->elt->set($key, $value);
$this->assertSame($value, $result->get($key));
$result->un_set($key);
$this->assertNull($result->get($key));
}
示例2: valid
public function valid()
{
if ($this->_position == 0 && !isset($this->_item->elements[$this->identifier], $this->_item->elements[$this->identifier][0])) {
parent::set(0, array());
}
return parent::get($this->_position) !== null;
}
示例3: set
/**
* Overridden to handle key=class.
*
* (non-PHPdoc)
* @see classes/core/Element#set($key, $val)
*/
public function set($key, $val = null)
{
if (strtolower($key) == 'class') {
return $this->setClass($val);
}
// In all other cases
return parent::set($key, $val);
}
示例4: set
/**
* Set value to the given key.
* If $addToArray is true, existing keys will not be overwritten, rather,
* if the new value is already in the map, it will be added into an array.
*
* @param String $key
* @param String $val
* @param Boolean $addToArray
* @return Href
*/
public function set($key, $val = null, $addToArray = false)
{
// Serialize value if it's an object
if (is_object($val)) {
$val = $val->__toString();
}
// Support 'addToArray', if new value is not an array.
if ($addToArray && !is_array($val)) {
$existingVal = $this->get($key);
// If there is an existing value
if ($existingVal !== null) {
// Turn existing value into an array (if it's not already)
if (!is_array($existingVal)) {
$existingVal = array($existingVal);
}
// Add new value to array
$existingVal[] = $val;
// Set the array into '$val' and proceed normally
$val = $existingVal;
}
}
return parent::set($key, $val);
}