本文整理匯總了PHP中HtmlObject\Element::setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Element::setAttribute方法的具體用法?PHP Element::setAttribute怎麽用?PHP Element::setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HtmlObject\Element
的用法示例。
在下文中一共展示了Element::setAttribute方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fromHtml
public static function fromHtml($html)
{
$dom = new HtmlDomParser();
$r = $dom->str_get_html($html);
$nodes = $r->childNodes();
$node = $nodes[0];
$element = new Element($node->tag);
foreach ($node->getAllAttributes() as $key => $value) {
$element->setAttribute($key, $value);
}
$column = new static($element);
return $column;
}
示例2: getPresetContainerHtmlObject
public function getPresetContainerHtmlObject()
{
$dom = new HtmlDomParser();
$r = $dom->str_get_html($this->arrayPreset['container']);
if (is_object($r)) {
$nodes = $r->childNodes();
$node = $nodes[0];
if (is_object($node)) {
$element = new Element($node->tag);
foreach ($node->getAllAttributes() as $key => $value) {
$element->setAttribute($key, $value);
}
}
}
if (!isset($element)) {
$element = new Element('div');
}
return $element;
}
示例3: __toString
/**
* @return string
*/
public function __toString()
{
$e = new Element('script');
$e->type('text/javascript')->src($this->getAssetURL());
if (count($this->combinedAssetSourceFiles)) {
$source = '';
foreach ($this->combinedAssetSourceFiles as $file) {
$source .= $file . ' ';
}
$source = trim($source);
$e->setAttribute('data-source', $source);
}
return (string) $e;
}