我意识到DOMNodeList是一种特殊类型的“实时”只读参考列表,但出于好奇,它是如何由其他类构建的?例如,DOMNode“getBy *”函数如何构造DOMNodeList?
//for example NOT with array of nodes
$doc=new DOMDocument();
$doc->loadHTML("<div></div><div></div>");
$list=new DOMNodeList([$doc->getElementsByTagName('div')->item(0)]);
echo $list->length;//doesn't work; empty; prints 0