3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = <<<'XML' <foo bar="baz" tab="taz"> <bar> </foo> XML; $xml = new SimpleXmlElement($xml); var_dump($xml->getName()); var_dump($xml->attributes()); var_dump($xml->children());
Output for 7.0.6 - 7.2.0
Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Opening and ending tag mismatch: bar line 2 and foo in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): </foo> in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): ^ in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Premature end of data in tag foo line 1 in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): </foo> in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): ^ in /in/9sXna on line 9 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/9sXna:9 Stack trace: #0 /in/9sXna(9): SimpleXMLElement->__construct('<foo bar="baz" ...') #1 {main} thrown in /in/9sXna on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.5
Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Opening and ending tag mismatch: bar line 2 and foo in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Premature end of data in tag foo line 1 in /in/9sXna on line 9 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/9sXna:9 Stack trace: #0 /in/9sXna(9): SimpleXMLElement->__construct('<foo bar="baz" ...') #1 {main} thrown in /in/9sXna on line 9
Process exited with code 255.
Output for 5.5.24 - 5.5.28, 5.5.35 - 5.6.12, 5.6.21 - 5.6.28
Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Opening and ending tag mismatch: bar line 2 and foo in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): </foo> in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): ^ in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Premature end of data in tag foo line 1 in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): </foo> in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): ^ in /in/9sXna on line 9 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/9sXna:9 Stack trace: #0 /in/9sXna(9): SimpleXMLElement->__construct('<foo bar="baz" ...') #1 {main} thrown in /in/9sXna on line 9
Process exited with code 255.
Output for 5.3.21 - 5.4.45, 5.5.29 - 5.5.34, 5.6.13 - 5.6.20
Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Opening and ending tag mismatch: bar line 2 and foo in /in/9sXna on line 9 Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Premature end of data in tag foo line 1 in /in/9sXna on line 9 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/9sXna:9 Stack trace: #0 /in/9sXna(9): SimpleXMLElement->__construct('<foo bar="baz" ...') #1 {main} thrown in /in/9sXna on line 9
Process exited with code 255.