DOMElement->hasAttribute()
DOMElement->hasAttribute() — 属性が存在するかどうかを調べる
説明
class DOMElement {bool hasAttribute ( string name )
} 要素のメンバとして name という名前の属性が 存在するかどうかを示します。
パラメータ
- name
-
要素名。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。参考
DOMElement->hasAttributeNS() |
DOMElement->getAttribute() |
DOMElement->setAttribute() |
DOMElement->removeAttribute() |
DomElement->has_attribute()
DomElement->has_attribute() — 現在のノードに属性があるかどうかを調べる
説明
class DomElement {bool has_attribute ( string name )
} この関数は、現在のノードに名前 name を持つ属性があるかどうかを調べます。
パラメータ
- name
-
検査する属性名
返り値
もし問い合わせた属性が存在する場合 TRUE、そうでない場合 FALSE を返します。例
例 531. 属性の存在を調べる
<?php
include("example.inc");
if (!$dom = domxml_open_mem($xmlstr)) {
echo "Error while parsing the document\n";
exit;
}
$root = $dom->document_element();
$buffer = '<html';
if ($root->has_attribute('language')) {
$buffer .= 'lang="' . $root->get_attribute('language') . '"';
}
$buffer .= '>';
?>
PHP 5 への移行
DOMElement->hasAttribute() を使用してください。- DOMElement->hasAttribute()のページへのリンク