DomElement->has_attribute
(PHP 4 >= 4.1.0)
DomElement->has_attribute — Verifica si un atributo existe en el nodo actual
Descripción
bool DomElement::has_attribute
( string $name
)
Esta función verifica si un atributo con el name dado existe en el nodo actual.
Parámetros
- name
-
El nombre del atributo probado.
Valores devueltos
Devuelve TRUE si el atributo solicitado existe, FALSE de lo contrario.
Ejemplos
Example #1 Probar la existencia de un atributo
<?php
include("ejemplo.inc");
if (!$dom = domxml_open_mem($cadena_xml)) {
echo "Ocurrió un error al interpretar el documento\n";
exit;
}
$raiz = $dom->document_element();
$bufer = '<html';
if ($raiz->has_attribute('language')) {
$buffer .= 'lang="' . $raiz->get_attribute('language') . '"';
}
$bufer .= '>';
?>
Migración a PHP 5
There are no user contributed notes for this page.
