array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'dom-tokenlist.item.php', 1 => 'Dom\\TokenList::item', 2 => 'Returns a token from the list', ), 'up' => array ( 0 => 'class.dom-tokenlist.php', 1 => 'Dom\\TokenList', ), 'prev' => array ( 0 => 'dom-tokenlist.getiterator.php', 1 => 'Dom\\TokenList::getIterator', ), 'next' => array ( 0 => 'dom-tokenlist.remove.php', 1 => 'Dom\\TokenList::remove', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/dom/dom/tokenlist/item.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8 >= 8.4.0)
Dom\TokenList::item — Returns a token from the list
index
Returns the token at index
or null
when the index
is out of bounds.
示例 #1 Dom\TokenList::item() example
Accesses a valid index and an invalid index.
<?php
$dom = Dom\HTMLDocument::createFromString('<p class="font-bold important"></p>', LIBXML_NOERROR);
$p = $dom->body->firstChild;
$classList = $p->classList;
var_dump(
$classList->item(0),
$classList->item(100),
);
?>
以上示例会输出:
string(9) "font-bold" NULL
注意: This method is equivalent to using array access syntax.