1--TEST-- 2libxml_set_external_entity_loader() variation: restore original handler; returning NULL 3--SKIPIF-- 4<?php if (!extension_loaded('dom')) die('skip'); ?> 5--CLEAN-- 6<?php 7@unlink(__DIR__ . "/foobar.dtd"); 8--FILE-- 9<?php 10chdir(__DIR__); 11$xml = <<<XML 12<!DOCTYPE foo PUBLIC "-//FOO/BAR" "foobar.dtd"> 13<foo>bar</foo> 14XML; 15 16$dtd = <<<DTD 17<!ELEMENT foo (#PCDATA)> 18DTD; 19 20 21libxml_set_external_entity_loader( 22 function ($public, $system, $context) { 23 var_dump($public,$system); 24 return null; 25 } 26); 27 28$dd = new DOMDocument; 29$r = $dd->loadXML($xml); 30var_dump($dd->validate()); 31 32libxml_set_external_entity_loader(NULL); 33file_put_contents(__DIR__ . "/foobar.dtd", $dtd); 34var_dump($dd->validate()); 35 36echo "Done.\n"; 37--EXPECTF-- 38string(10) "-//FOO/BAR" 39string(%d) "%sfoobar.dtd" 40 41Warning: DOMDocument::validate(): Could not load the external subset "foobar.dtd" in %s on line %d 42bool(false) 43bool(true) 44Done. 45