3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function ReadXml($xmlstr) { $xml = new \SimpleXmlElement($xmlstr); echo $xml->getName() . PHP_EOL; foreach ($xml as $child) { echo $child->getName() . ': ' . $child . PHP_EOL; } } $xmlstr= '<Address><to>James</to><from>Jani</from><heading>Reminder</heading><body>Please check your mail.</body></Address>'; ReadXml($xmlstr);
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
Address to: James from: Jani heading: Reminder body: Please check your mail.
Output for 5.1.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UGltt on line 5 Address to: James from: Jani heading: Reminder body: Please check your mail.
Output for 5.0.0 - 5.1.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UGltt on line 5 Fatal error: Call to undefined method SimpleXMLElement::getName() in /in/UGltt on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UGltt on line 5 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/UGltt on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UGltt on line 5 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/UGltt on line 5