php8.5
Home/ Manual/ dom / attr/ Dom\Attr::isId

Dom\Attr::isId

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Description

Dom\Attr::isId(): bool

According to the DOM standard this requires a DTD which defines the attribute ID to be of type ID. To utilise this method the document must be validated at parse time by passing LIBXML_DTDVALID as an option.

Parameters Parameters

Examples

Dom\Attr::isId() Example

php
<?php

// We need to validate our document before referring to the id
$doc = Dom\XMLDocument::createFromFile('examples/book-docbook.xml', LIBXML_DTDVALID);

// We retrieve the attribute named id of the chapter element
$attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id');

var_dump($attr->isId()); // bool(true)

?>

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