3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = new SimpleXMLElement( '<person> <child role="son"> <child role="daughter"/> </child> <child_under role="daughter"> <child role="son"> <child role="son"/> </child> </child> </person>'); foreach ($xml->children() as $second_gen) { echo ' The person begot a ' . $second_gen['role']; foreach ($second_gen->children() as $third_gen) { echo ' who begot a ' . $third_gen['role'] . ';'; foreach ($third_gen->children() as $fourth_gen) { echo ' and that ' . $third_gen['role'] . ' begot a ' . $fourth_gen['role']; } } } ?>
based on vr8IP
Output for 7.0.0 - 7.1.0
Warning: SimpleXMLElement::__construct(): Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): </child> in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): ^ in /in/8OBJX on line 12 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/8OBJX:12 Stack trace: #0 /in/8OBJX(12): SimpleXMLElement->__construct('<person>\n <chil...') #1 {main} thrown in /in/8OBJX on line 12
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/8OBJX:12 Stack trace: #0 /in/8OBJX(12): SimpleXMLElement->__construct() #1 {main} Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child </child> ^
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.4.29 - 5.6.28
Warning: SimpleXMLElement::__construct(): Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): </child> in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): ^ in /in/8OBJX on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/8OBJX:12 Stack trace: #0 /in/8OBJX(12): SimpleXMLElement->__construct('<person>\n <chil...') #1 {main} thrown in /in/8OBJX on line 12
Process exited with code 255.
Output for 5.4.27 - 5.4.28
Warning: SimpleXMLElement::__construct(): Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): </child> in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): ^ in /in/8OBJX on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/8OBJX:12 Stack trace: #0 /in/8OBJX(12): SimpleXMLElement->__construct('<person>\n <chiil..') #1 {main} thrown in /in/8OBJX on line 12
Process exited with code 255.
Output for 5.1.0 - 5.4.26
Warning: SimpleXMLElement::__construct(): Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): </child> in /in/8OBJX on line 12 Warning: SimpleXMLElement::__construct(): ^ in /in/8OBJX on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/8OBJX:12 Stack trace: #0 /in/8OBJX(12): SimpleXMLElement->__construct('<person>? <chil...') #1 {main} thrown in /in/8OBJX on line 12
Process exited with code 255.
Output for 5.0.3 - 5.0.5
Warning: Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child in /in/8OBJX on line 12 Warning: </child> in /in/8OBJX on line 12 Warning: ^ in /in/8OBJX on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/8OBJX:12 Stack trace: #0 /in/8OBJX(12): SimpleXMLElement->__construct('<person>? <chil...') #1 {main} thrown in /in/8OBJX on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Warning: Entity: line 9: parser error : Opening and ending tag mismatch: child_under line 5 and child in /in/8OBJX on line 12 Warning: </child> in /in/8OBJX on line 12 Warning: ^ in /in/8OBJX on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/8OBJX:12 Stack trace: #0 {main} thrown in /in/8OBJX on line 12
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/8OBJX on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/8OBJX on line 2