DomElement::has_attribute
(PHP 4 >= 4.1.0)
DomElement::has_attribute — Comprueba si un atributo existe en el nodo actual
Descripción
bool DomElement::has_attribute
( string
$name
)
Esta función comprueba si un atributo llamado
name existe en el nodo actual.
Parámetros
-
name -
El nombre de el atributo de prueba.
Valores devueltos
Devuelve TRUE si el atributo consultado existe, FALSE en caso contrario.
Ejemplos
Ejemplo #1 Prueba de la existencia de un atributo
<?php
include("example.inc");
if (!$dom = domxml_open_mem($xmlstr)) {
echo "Error al analizar el documento\n";
exit;
}
$root = $dom->document_element();
$buffer = '<html';
if ($root->has_attribute('language')) {
$buffer .= 'lang="' . $root->get_attribute('language') . '"';
}
$buffer .= '>';
?>
Migrando a PHP 5
There are no user contributed notes for this page.
