1--TEST-- 2Delayed freeing entity declaration 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7$doc = new DOMDocument; 8$doc->loadXML(<<<'XML' 9<?xml version="1.0"?> 10<!DOCTYPE books [ 11<!ENTITY test "entity is only for test purposes"> 12<!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF> 13]> 14<container/> 15XML); 16$ref1 = $doc->createEntityReference("test"); 17$ref2 = $doc->createEntityReference("myimage"); 18$entity1 = $doc->doctype->entities[0]; 19$entity2 = $doc->doctype->entities[1]; 20if (strcmp($entity1->nodeName, $entity2->nodeName) < 0) { 21 // Entity ordering depends on the addresses 22 [$entity1, $entity2] = [$entity2, $entity1]; 23} 24var_dump($entity1->nodeName, $entity1->parentNode->nodeName); 25var_dump($entity2->nodeName, $entity2->parentNode->nodeName); 26$doc->removeChild($doc->doctype); 27var_dump($entity1->nodeName, $entity1->parentNode); 28var_dump($entity2->nodeName, $entity2->parentNode); 29?> 30--EXPECT-- 31string(4) "test" 32string(5) "books" 33string(7) "myimage" 34string(5) "books" 35string(4) "test" 36NULL 37string(7) "myimage" 38NULL 39