3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function ReadXml($xmlstr) { $xml = new \SimpleXmlElement($xmlstr); echo $xml->getName() . PHP_EOL; foreach ($xml as $child) { var_dump($child->getName()); } } $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 - 7.2.0
Address string(2) "to" string(4) "from" string(7) "heading" string(4) "body"
Output for 5.1.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/27ZiE on line 5 Address string(2) "to" string(4) "from" string(7) "heading" string(4) "body"
Output for 5.0.0 - 5.1.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/27ZiE on line 5 Fatal error: Call to undefined method SimpleXMLElement::getName() in /in/27ZiE 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/27ZiE on line 5 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/27ZiE 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/27ZiE on line 5 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/27ZiE on line 5