3v4l.org

run code in 200+ PHP versions simultaneously
<?php $data='<data> <seg id="A1"/> <seg id="A2"/> <seg id="A3"/> <seg id="A4"/> <seg id="A5"/> </data>'; $doc=new SimpleXMLElement($data); $seg_ref = $doc->seg; unset($seg_ref[0]); echo $doc->asXml();
Output for 5.1.3 - 7.3.1
<?xml version="1.0"?> <data> <seg id="A2"/> <seg id="A3"/> <seg id="A4"/> <seg id="A5"/> </data>
Output for 5.0.0 - 5.1.2
<?xml version="1.0"?> <data> <seg id="A1"/> <seg id="A2"/> <seg id="A3"/> <seg id="A4"/> <seg id="A5"/> </data>
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/rtSBr on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/rtSBr on line 9