3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string="<xml>a & b</xml"; $xml = new SimpleXMLElement($string); print_r($xml);
based on pciYG
Output for 7.0.6 - 7.2.0
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : xmlParseEntityRef: no name in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): <xml>a & b</xml in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): ^ in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : expected '>' in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): <xml>a & b</xml in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): ^ in /in/X7gcO8 on line 5 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/X7gcO8:5 Stack trace: #0 /in/X7gcO8(5): SimpleXMLElement->__construct('<xml>a & b</xml') #1 {main} thrown in /in/X7gcO8 on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.5
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : xmlParseEntityRef: no name in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): <xml>a & b</xml in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): ^ in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : expected '>' in /in/X7gcO8 on line 5 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/X7gcO8:5 Stack trace: #0 /in/X7gcO8(5): SimpleXMLElement->__construct('<xml>a & b</xml') #1 {main} thrown in /in/X7gcO8 on line 5
Process exited with code 255.
Output for 5.3.19 - 5.5.28, 5.5.35 - 5.6.12, 5.6.21 - 5.6.28
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : xmlParseEntityRef: no name in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): <xml>a & b</xml in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): ^ in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : expected '>' in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): <xml>a & b</xml in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): ^ in /in/X7gcO8 on line 5 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/X7gcO8:5 Stack trace: #0 /in/X7gcO8(5): SimpleXMLElement->__construct('<xml>a & b</xml') #1 {main} thrown in /in/X7gcO8 on line 5
Process exited with code 255.
Output for 5.5.29 - 5.5.34, 5.6.13 - 5.6.20
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : xmlParseEntityRef: no name in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): <xml>a & b</xml in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): ^ in /in/X7gcO8 on line 5 Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : expected '>' in /in/X7gcO8 on line 5 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/X7gcO8:5 Stack trace: #0 /in/X7gcO8(5): SimpleXMLElement->__construct('<xml>a & b</xml') #1 {main} thrown in /in/X7gcO8 on line 5
Process exited with code 255.