EZ

Eduzan

Learning Hub

Eduzan
Eduzan / PHP

DOM Function

__construct()
Description: Constructs a new DOMAttr object. This is used to create an attribute node with a specified name and value.
Example:

$doc = new DOMDocument();
$attr = new DOMAttr("id", "unique-value");
echo $attr->name;  // Output: id
echo $attr->value; // Output: unique-value

isId()
Description: Checks if this attribute is an ID attribute.
Example:

$doc = new DOMDocument();
$element = $doc->createElement("example");
$attr = $doc->createAttribute("id");
$attr->value = "unique-id";
$element->setAttributeNode($attr);
echo $attr->isId() ? "true" : "false";
// Output: true (if the attribute is declared as an ID in a DTD)
End of lesson.