3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $div = '<div class="1"><span class="test">text text text</span></div> <div class="2"><span class="test">text text text</span></div> <div class="3"><span class="test">text text text</span></div>'; $dom = new \DOMDocument( '1.0', 'UTF-8' ); $dom->loadXML( "<content>{$div}</content>" ); /** @var \DOMNodeList $node */ $list = $dom->getElementsByTagName( 'div' ); /** @var \DOMElement $node */ #$node = $list->item( $list->length -1 ); var_dump( $dom->saveXML( $list ) );
based on jvE0K
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to DOMDocument::saveXML() must be an instance of DOMNode or null, instance of DOMNodeList given in /in/1SfOL:14 Stack trace: #0 /in/1SfOL(14): DOMDocument->saveXML(Object(DOMNodeList)) #1 {main} thrown in /in/1SfOL on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught TypeError: Argument 1 passed to DOMDocument::saveXML() must be an instance of DOMNode, instance of DOMNodeList given in /in/1SfOL:14 Stack trace: #0 /in/1SfOL(14): DOMDocument->saveXML(Object(DOMNodeList)) #1 {main} thrown in /in/1SfOL on line 14
Process exited with code 255.
Output for 5.3.17 - 5.6.28
Catchable fatal error: Argument 1 passed to DOMDocument::saveXML() must be an instance of DOMNode, instance of DOMNodeList given in /in/1SfOL on line 14
Process exited with code 255.