3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don\'t forget me this weekend!</body> <recursive> <val>2</val> <val>4</val> </recursive> </note>'; $xml1 = new SimpleXmlIterator($filePath, 0, false); $xml = (array) $xml1; echo $xml['note']['to']; echo $xml['note']['recursive']['val'][0];
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $filePath in /in/2A9q5 on line 16 Deprecated: SimpleXMLElement::__construct(): Passing null to parameter #1 ($data) of type string is deprecated in /in/2A9q5 on line 16 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLElement->__construct('', 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $filePath in /in/2A9q5 on line 16 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLElement->__construct('', 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: filePath in /in/2A9q5 on line 16 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLElement->__construct('', 0, false) #1 {main} thrown in /in/2A9q5 on line 16
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/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLElement->__construct('', 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Notice: Undefined variable: filePath in /in/2A9q5 on line 16 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLElement->__construct('', 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 5.0.5, 5.1.0 - 5.1.1
Notice: Undefined variable: filePath in /in/2A9q5 on line 16 Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects exactly 1 parameter, 3 given' in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLElement->__construct(NULL, 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 5.0.4
Notice: Undefined variable: filePath in /in/2A9q5 on line 16 Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects exactly 1 parameter, 3 given' in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLIterator->__construct(NULL, 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 5.0.3
Notice: Undefined variable: filePath in /in/2A9q5 on line 16 Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects exactly 1 parameter, 3 given' in /in/2A9q5:16 Stack trace: #0 /in/2A9q5(16): SimpleXMLIterator->__construct(NULL, 0, false) #1 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Notice: Undefined variable: filePath in /in/2A9q5 on line 16 Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects exactly 1 parameter, 3 given' in /in/2A9q5:16 Stack trace: #0 {main} thrown in /in/2A9q5 on line 16
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/2A9q5 on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/2A9q5 on line 16

preferences:
246.96 ms | 401 KiB | 356 Q