本文整理匯總了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);
}