简介
PHP Manual
PHP Manual»DOM»DOMNodeList

The DOMNodeList class

(PHP 5, PHP 7, PHP 8)

Represents a live list of nodes.

class DOMNodeList implements IteratorAggregate, Countable {
/* 属性 */
public readonly int $length;
/* 方法 */
public function count(): int
public function getIterator(): Iterator
public function item(int $index): DOMElement|DOMNode|DOMNameSpaceNode|null
}
length

The number of nodes in the list. The range of valid child node indices is 0 to length - 1 inclusive.

版本 说明
8.0.0 DOMNodeList implements IteratorAggregate now. Previously, Traversable was implemented instead.
7.2.0 The Countable interface is implemented and returns the value of the length property.

注意: Nodes in the list can be accessed by array syntax.

目录

To Top