3v4l.org

run code in 300+ PHP versions simultaneously
<?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( 'p' ); /** @var \DOMElement $node */ # $node = $list->item( $list->length -1 ); var_dump( $dom->saveXML( $list ) );
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: DOMDocument::saveXML(): Argument #1 ($node) must be of type ?DOMNode, DOMNodeList given in /in/raCoS:14 Stack trace: #0 /in/raCoS(14): DOMDocument->saveXML(Object(DOMNodeList)) #1 {main} thrown in /in/raCoS on line 14
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to DOMDocument::saveXML() must be an instance of DOMNode or null, instance of DOMNodeList given in /in/raCoS:14 Stack trace: #0 /in/raCoS(14): DOMDocument->saveXML(Object(DOMNodeList)) #1 {main} thrown in /in/raCoS 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/raCoS:14 Stack trace: #0 /in/raCoS(14): DOMDocument->saveXML(Object(DOMNodeList)) #1 {main} thrown in /in/raCoS on line 14
Process exited with code 255.
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Catchable fatal error: Argument 1 passed to DOMDocument::saveXML() must be an instance of DOMNode, instance of DOMNodeList given in /in/raCoS on line 14
Process exited with code 255.

preferences:
184.04 ms | 402 KiB | 242 Q