3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * @link http://stackoverflow.com/q/24526493/367456 */ $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" "http://jats.nlm.nih.gov/publishing/1.0/JATS-journalpublishing1.dtd"> <article/> XML; libxml_set_external_entity_loader(function() { var_dump(func_get_args()); return NULL; }); $doc = new DOMDocument; $doc->loadXML($xml, LIBXML_DTDLOAD); echo "----\n"; libxml_set_external_entity_loader(NULL); $doc = new DOMDocument; $doc->loadXML($xml, LIBXML_DTDLOAD);
Output for 5.4.0 - 7.1.0
array(3) { [0]=> string(66) "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" [1]=> string(66) "http://jats.nlm.nih.gov/publishing/1.0/JATS-journalpublishing1.dtd" [2]=> array(4) { ["directory"]=> string(1) "/" ["intSubName"]=> string(7) "article" ["extSubURI"]=> string(66) "http://jats.nlm.nih.gov/publishing/1.0/JATS-journalpublishing1.dtd" ["extSubSystem"]=> string(66) "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" } } Warning: DOMDocument::loadXML(): Failed to load external entity "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" in Entity, line: 2 in /in/jemmH on line 18 ---- Warning: DOMDocument::loadXML(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/jemmH on line 25 Warning: DOMDocument::loadXML(http://jats.nlm.nih.gov/publishing/1.0/JATS-journalpublishing1.dtd): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/jemmH on line 25 Notice: DOMDocument::loadXML(): failed to load external entity "http://jats.nlm.nih.gov/publishing/1.0/JATS-journalpublishing1.dtd" in Entity, line: 2 in /in/jemmH on line 25
Output for 5.3.0 - 5.3.29
Fatal error: Call to undefined function libxml_set_external_entity_loader() in /in/jemmH on line 12
Process exited with code 255.
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/jemmH on line 12
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/jemmH on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/jemmH on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/jemmH on line 12
Process exited with code 255.