3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dom = new DOMDocument; $dom->loadXML('<foo>foo1<x/></foo>'); $nodes = $dom->documentElement->childNodes; $iter = $nodes->getIterator(); $clone = clone $iter; var_dump($iter->current()); var_dump($clone->current()); $iter->next(); var_dump($iter->current()); var_dump($clone->current());
Output for 8.2.22 - 8.2.23, 8.3.10 - 8.3.11
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class InternalIterator in /in/QR1NS:6 Stack trace: #0 {main} thrown in /in/QR1NS on line 6
Process exited with code 255.
Output for 8.3.0 - 8.3.9
object(DOMText)#5 (23) { ["wholeText"]=> string(4) "foo1" ["data"]=> string(4) "foo1" ["length"]=> int(4) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(4) "foo1" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(4) "foo1" }
Process exited with code 139.
Output for 8.0.0, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21
object(DOMText)#5 (21) { ["wholeText"]=> string(4) "foo1" ["data"]=> string(4) "foo1" ["length"]=> int(4) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(4) "foo1" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(4) "foo1" }
Process exited with code 139.
Output for 7.0.25, 7.3.14
Fatal error: Uncaught Error: Call to undefined method DOMNodeList::getIterator() in /in/QR1NS:5 Stack trace: #0 {main} thrown in /in/QR1NS on line 5
Process exited with code 255.

preferences:
51.26 ms | 411 KiB | 5 Q