3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data=' <root> <element> <feed id="9"> <title>test</title> <table>feeds</table> <link/> <feed_type>API</feed_type> <affiliate/> <mwst>ja</mwst> <tld>DE</tld> <query/> </feed> <feed id="10"> <title>test</title> <table>feeds</table> <link/> <feed_type>API</feed_type> <affiliate/> <mwst>ja</mwst> <tld>DE</tld> <query/> </feed> </element> </root>'; function deleteNode($feed_id) { global $xml; $doc = new SimpleXMLElement($data); foreach($doc->feed as $feed){ if($feed['id'] == $feed_id) { $dom=dom_import_simplexml($feed); $dom->parentNode->removeChild($dom); } } } echo "\n"; deleteNode("10"); echo $xml->asXML();
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $data in /in/jZa5O on line 30 Deprecated: SimpleXMLElement::__construct(): Passing null to parameter #1 ($data) of type string is deprecated in /in/jZa5O on line 30 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $data in /in/jZa5O on line 30 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
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/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 5.0.3
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(39): deleteNode('') #1 {main} thrown in /in/jZa5O on line 30
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: simplexmlelement in /in/jZa5O on line 30
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/jZa5O on line 30

preferences:
226.69 ms | 401 KiB | 311 Q