3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlstr = <<<XML <?xml version='1.0' standalone='yes'?> <medium val="organic"> <source val=""> <campaign val=""> <lever3 val="seo" /> <lever2 val="seo" /> <lever1 val="trafic_gratuit" /> </campaign> </source> </medium> <medium val="cpc"> <source val=""> <campaign val="remarketing"> <lever3 val="sem-remarketing" /> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> </source> <source val="leguide"> <campaign val=""> <lever3 val="comparateur-leguide" /> <lever2 val="comparateur" /> <lever1 val="trafic_payant" /> </campaign> </source> <source val="google"> <campaign val="marque"> <lever3 val="sem-marque-google" /> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> <campaign val="auchan-fil_rouge"> <lever3 val="sem-marque-google" /> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> <campaign val="horsmarque"> <lever3 val="sem-hors-marque-google" /> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> </source> <source val="bing"> <campaign val="auchan-fil_rouge"> <lever3 val="sem-marque-yahoo_bing" /> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> <campaign val="marque"> <lever3 val="sem-marque-yahoo_bing"/> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> <campaign val="horsmarque"> <lever3 val="sem-horsmarque-yahoo_bing"/> <lever2 val="sem" /> <lever1 val="trafic_payant" /> </campaign> </source> </medium> <medium val="cpa"> <source val="affilinet"> <campaign val=""> <lever3 val="affiliation" /> <lever2 val="affiliation" /> <lever1 val="trafic_payant" /> </campaign> </source> </medium> <!-- ETC --> XML; $xml = new SimpleXMLElement($xmlstr); $res = $xml->xpath("/medium/atribute::cpa"); while(list( , $node) = each($res)) { echo '/a/b/c: ',$node,"\n"; }
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : XML declaration allowed only at the start of the document in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): <?xml version='1.0' standalone='yes'?> in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): ^ in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): Entity: line 13: parser error : Extra content at the end of the document in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): <medium val="cpc"> in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): ^ in /in/UjrKq on line 78 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/UjrKq:78 Stack trace: #0 /in/UjrKq(78): SimpleXMLElement->__construct(' <?xml versi...') #1 {main} thrown in /in/UjrKq on line 78
Process exited with code 255.
Output for 5.2.3 - 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.40
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : XML declaration allowed only at the start of the document in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): <?xml version='1.0' standalone='yes'?> in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): ^ in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): Entity: line 13: parser error : Extra content at the end of the document in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): <medium val="cpc"> in /in/UjrKq on line 78 Warning: SimpleXMLElement::__construct(): ^ in /in/UjrKq on line 78 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/UjrKq:78 Stack trace: #0 /in/UjrKq(78): SimpleXMLElement->__construct(' <?xml versi...') #1 {main} thrown in /in/UjrKq on line 78
Process exited with code 255.
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.SimpleXMLElement---construct'>function.SimpleXMLElement---construct</a>]: Entity: line 1: parser error : XML declaration allowed only at the start of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.SimpleXMLElement---construct'>function.SimpleXMLElement---construct</a>]: &lt;?xml version='1.0' standalone='yes'?&gt; in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.SimpleXMLElement---construct'>function.SimpleXMLElement---construct</a>]: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.SimpleXMLElement---construct'>function.SimpleXMLElement---construct</a>]: Entity: line 13: parser error : Extra content at the end of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.SimpleXMLElement---construct'>function.SimpleXMLElement---construct</a>]: &lt;medium val=&quot;cpc&quot;&gt; in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.SimpleXMLElement---construct'>function.SimpleXMLElement---construct</a>]: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/UjrKq:78 Stack trace: #0 /in/UjrKq(78): SimpleXMLElement-&gt;__construct(' &lt;?xml versi...') #1 {main} thrown in <b>/in/UjrKq</b> on line <b>78</b><br />
Process exited with code 255.
Output for 5.1.2
<br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: Entity: line 1: parser error : XML declaration allowed only at the start of the document in <b>/in/UjrKq</b> on line <b>79</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: &lt;?xml version='1.0' standalone='yes'?&gt; in <b>/in/UjrKq</b> on line <b>79</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: ^ in <b>/in/UjrKq</b> on line <b>79</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: Entity: line 13: parser error : Extra content at the end of the document in <b>/in/UjrKq</b> on line <b>79</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: &lt;medium val=&quot;cpc&quot;&gt; in <b>/in/UjrKq</b> on line <b>79</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: ^ in <b>/in/UjrKq</b> on line <b>79</b><br /> <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/UjrKq:79 Stack trace: #0 /in/UjrKq(79): SimpleXMLElement-&gt;__construct(' &lt;?xml versi...') #1 {main} thrown in <b>/in/UjrKq</b> on line <b>79</b><br />
Process exited with code 255.
Output for 5.1.0 - 5.1.1
<br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: Entity: line 1: parser error : XML declaration allowed only at the start of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: &lt;?xml version='1.0' standalone='yes'?&gt; in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: Entity: line 13: parser error : Extra content at the end of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: &lt;medium val=&quot;cpc&quot;&gt; in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: SimpleXMLElement::__construct() [<a href='function.--construct'>function.--construct</a>]: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/UjrKq:78 Stack trace: #0 /in/UjrKq(78): SimpleXMLElement->__construct(' <?xml versi...') #1 {main} thrown in <b>/in/UjrKq</b> on line <b>78</b><br />
Process exited with code 255.
Output for 5.0.3 - 5.0.5
<br /> <b>Warning</b>: Entity: line 1: parser error : XML declaration allowed only at the start of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: <?xml version='1.0' standalone='yes'?> in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: Entity: line 13: parser error : Extra content at the end of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: <medium val="cpc"> in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/UjrKq:78 Stack trace: #0 /in/UjrKq(78): SimpleXMLElement->__construct(' <?xml versi...') #1 {main} thrown in <b>/in/UjrKq</b> on line <b>78</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.2
<br /> <b>Warning</b>: Entity: line 1: parser error : XML declaration allowed only at the start of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: <?xml version='1.0' standalone='yes'?> in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: Entity: line 13: parser error : Extra content at the end of the document in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: <medium val="cpc"> in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Warning</b>: ^ in <b>/in/UjrKq</b> on line <b>78</b><br /> <br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/UjrKq:78 Stack trace: #0 {main} thrown in <b>/in/UjrKq</b> on line <b>78</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: simplexmlelement in <b>/in/UjrKq</b> on line <b>78</b><br />
Process exited with code 255.
Output for 4.4.2
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: simplexmlelement in <b>/in/UjrKq</b> on line <b>79</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: simplexmlelement in <b>/in/UjrKq</b> on line <b>78</b><br />

preferences:
339.91 ms | 401 KiB | 460 Q