php8.5
Home/ Manual/ dom / domdocument/ DOMDocument::createAttribute

DOMDocument::createAttribute

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Create new attribute

Description

DOMDocument::createAttribute(string $localName): DOMAttr|false

This function creates a new instance of class DOMAttr. Inserted

Parameters

localName

The name of the attribute.

Return Values

The new DOMAttr or false if an error occurred.

Errors/Exceptions

May throw a DOMException with the following error codes:

DOM_INVALID_CHARACTER_ERR

Raised if localName contains an invalid character.

See Also

  • DOMNode::appendChild
  • DOMDocument::createAttributeNS
  • DOMDocument::createCDATASection
  • DOMDocument::createComment
  • DOMDocument::createDocumentFragment
  • DOMDocument::createElement
  • DOMDocument::createElementNS
  • DOMDocument::createEntityReference
  • DOMDocument::createProcessingInstruction
  • DOMDocument::createTextNode

Source: reference/dom/domdocument/createattribute.xml · from the official PHP manual (php/doc-en)