DomElement::has_attribute
(PHP 4 >= 4.1.0)
DomElement::has_attribute — 現在のノードに属性があるかどうかを調べる
説明
bool DomElement::has_attribute
( string
$name
)
この関数は、現在のノードに名前 name
を持つ属性があるかどうかを調べます。
パラメータ
-
name -
検査する属性名
返り値
もし問い合わせた属性が存在する場合 TRUE、そうでない場合 FALSE
を返します。
例
例1 属性の存在を調べる
<?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 を使用してください。
There are no user contributed notes for this page.
