3v4l.org

run code in 300+ PHP versions simultaneously
<?php $buffer = <<<XML <?xml version="1.0"?> <!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "data://text/html,aaaa" >]><foo>&xxe;</foo> XML; libxml_disable_entity_loader(true); $xml = simplexml_load_string($buffer); var_dump($xml); echo "trying New SimpleXMLElement($xml)"; $xml = new SimpleXMLElement($buffer); var_dump($xml); echo 'Enabling LIBXML_NOENT for test reasons'; $xml = simplexml_load_string($buffer, 'SimpleXMLElement', LIBXML_NOENT); var_dump($xml);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Deprecated: Function libxml_disable_entity_loader() is deprecated in /in/pX2mO on line 10 object(SimpleXMLElement)#1 (1) { ["xxe"]=> object(SimpleXMLElement)#2 (1) { ["xxe"]=> object(SimpleXMLElement)#3 (0) { } } } trying New SimpleXMLElement()object(SimpleXMLElement)#2 (1) { ["xxe"]=> object(SimpleXMLElement)#1 (1) { ["xxe"]=> object(SimpleXMLElement)#3 (0) { } } } Enabling LIBXML_NOENT for test reasons Warning: simplexml_load_string(): I/O warning : failed to load external entity "data://text/html,aaaa" in /in/pX2mO on line 19 Warning: simplexml_load_string(): Entity: line 4: parser error : Failure to process entity xxe in /in/pX2mO on line 19 Warning: simplexml_load_string(): <!ENTITY xxe SYSTEM "data://text/html,aaaa" >]><foo>&xxe;</foo> in /in/pX2mO on line 19 Warning: simplexml_load_string(): ^ in /in/pX2mO on line 19 Warning: simplexml_load_string(): Entity: line 4: parser error : Entity 'xxe' not defined in /in/pX2mO on line 19 Warning: simplexml_load_string(): <!ENTITY xxe SYSTEM "data://text/html,aaaa" >]><foo>&xxe;</foo> in /in/pX2mO on line 19 Warning: simplexml_load_string(): ^ in /in/pX2mO on line 19 bool(false)
Output for 5.6.0 - 5.6.40, 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
object(SimpleXMLElement)#1 (1) { ["xxe"]=> object(SimpleXMLElement)#2 (1) { ["xxe"]=> object(SimpleXMLElement)#3 (0) { } } } trying New SimpleXMLElement()object(SimpleXMLElement)#2 (1) { ["xxe"]=> object(SimpleXMLElement)#1 (1) { ["xxe"]=> object(SimpleXMLElement)#3 (0) { } } } Enabling LIBXML_NOENT for test reasons Warning: simplexml_load_string(): I/O warning : failed to load external entity "data://text/html,aaaa" in /in/pX2mO on line 19 Warning: simplexml_load_string(): Entity: line 4: parser error : Failure to process entity xxe in /in/pX2mO on line 19 Warning: simplexml_load_string(): <!ENTITY xxe SYSTEM "data://text/html,aaaa" >]><foo>&xxe;</foo> in /in/pX2mO on line 19 Warning: simplexml_load_string(): ^ in /in/pX2mO on line 19 Warning: simplexml_load_string(): Entity: line 4: parser error : Entity 'xxe' not defined in /in/pX2mO on line 19 Warning: simplexml_load_string(): <!ENTITY xxe SYSTEM "data://text/html,aaaa" >]><foo>&xxe;</foo> in /in/pX2mO on line 19 Warning: simplexml_load_string(): ^ in /in/pX2mO on line 19 bool(false)

preferences:
234.59 ms | 405 KiB | 292 Q