3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: Undefined variable $xml in /in/vAO7F on line 14 Deprecated: SimpleXMLElement::__construct(): Passing null to parameter #1 ($data) of type string is deprecated 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 8.0.0 - 8.0.30
Warning: 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 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
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 7.3.32 - 7.3.33
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.5.24 - 5.5.35, 5.6.8 - 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.

preferences:
146.22 ms | 402 KiB | 185 Q