
DomTokenList::getIterator 메서드는 DOMTokenListIterator를 반환합니다.
DOMTokenListIterator는 Iterator 인터페이스를 구현한 것으로, DOMTokenList의 요소를 반복적으로 접근할 수 있습니다.
#hostingforum.kr
php
$domTokenList = new DomTokenList(['class', 'active']);
$iterator = $domTokenList->getIterator();
foreach ($iterator as $token) {
echo $token . "n";
}
DOMTokenListIterator는 DOMTokenList의 요소를 삭제할 수 없습니다.
#hostingforum.kr
php
$domTokenList = new DomTokenList(['class', 'active']);
$iterator = $domTokenList->getIterator();
$iterator->removeCurrent();
// $domTokenList의 요소가 삭제되지 않습니다.
echo $domTokenList->item(0) . "n"; // class
echo $domTokenList->item(1) . "n"; // active
DOMTokenListIterator는 DOMTokenList의 요소를 추가할 수 없습니다.
#hostingforum.kr
php
$domTokenList = new DomTokenList(['class', 'active']);
$iterator = $domTokenList->getIterator();
$iterator->add('disabled');
// $domTokenList의 요소가 추가되지 않습니다.
echo $domTokenList->item(0) . "n"; // class
echo $domTokenList->item(1) . "n"; // active
echo $domTokenList->item(2) . "n"; // disabled
2025-06-28 20:59