1--TEST-- 2Test: registerNodeClass() 3--SKIPIF-- 4<?php require_once('skipif.inc'); ?> 5--FILE-- 6<?php 7class myAttribute extends DOMAttr { 8 function testit() { return "HELLO Attribute"; } 9} 10 11class myElement extends DOMElement { 12 function testit() { return "HELLO Element"; } 13} 14 15$doc = new DOMDocument(); 16$doc->registerNodeClass('DOMAttr', 'myAttribute'); 17$doc->registerNodeClass('DOMElement', 'myElement'); 18$doc->appendChild(new DOMElement('root')); 19$root = $doc->documentElement; 20$root->setAttribute('a', 'a1'); 21echo get_class($root), "\n"; 22print $root->testit()."\n"; 23$attr = $root->getAttributeNode('a'); 24echo get_class($attr), "\n"; 25print $attr->testit()."\n"; 26unset($attr); 27$doc->registerNodeClass('DOMAttr', NULL); 28$attr = $root->getAttributeNode('a'); 29echo get_class($attr), "\n"; 30print $attr->testit()."\n"; 31?> 32--EXPECTF-- 33 34myElement 35HELLO Element 36myAttribute 37HELLO Attribute 38DOMAttr 39 40Fatal error: Uncaught Error: Call to undefined method DOMAttr::testit() in %s:25 41Stack trace: 42#0 {main} 43 thrown in %s on line 25 44