DOMElement::setAttributeNode
(PHP 5, PHP 7, PHP 8)
DOMElement::setAttributeNode — Adds new attribute node to element
Description
Adds new attribute node attr to element. If an attribute with the same name already exists on the element, that attribute is replaced by attr.
Parameters
attrThe attribute node.
Return Values
Returns the old attribute if it has been replaced or null if there was no old attribute. If a DOM_WRONG_DOCUMENT_ERR error is raised, and strictErrorChecking is false, false is returned.
Errors/Exceptions
May throw a DOMException with the following error codes:
DOM_WRONG_DOCUMENT_ERRRaised if
attrbelongs to a different document than the element.
See Also
- DOMElement::hasAttribute() - Checks to see if attribute exists
- DOMElement::getAttributeNode() - Returns attribute node
- DOMElement::removeAttributeNode() - Removes attribute
↑ and ↓ to navigate • Enter to select • Esc to close • / to open