3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $d = '<data> <items> <item> <sometag myattribute="foo">first node</sometag> </item> <item> <sometag myattribute="bar">second node</sometag> </item> </items> </data>'; $xmlobj = new SimpleXMLElement($xml); echo $xmlobj->items->item[0]->sometag; $d = '<data> <items> <item> <sometag myattribute="foo">first node</sometag> <sometag myattribute="ad">second node</sometag> </item> <item> <sometag myattribute="bar">second node</sometag> </item> </items> </data>'; $xmlobj = new SimpleXMLElement($xml); echo $xmlobj->items->item[0]->sometag;
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: xml in /in/vAO7F on line 14 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/vAO7F:14 Stack trace: #0 /in/vAO7F(14): SimpleXMLElement->__construct('') #1 {main} thrown in /in/vAO7F on line 14
Process exited with code 255.
Output for 5.3.22 - 5.6.28
Notice: Undefined variable: xml in /in/vAO7F on line 14 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/vAO7F:14 Stack trace: #0 /in/vAO7F(14): SimpleXMLElement->__construct('') #1 {main} thrown in /in/vAO7F on line 14
Process exited with code 255.