Extending DOMNode

From: Date: Thu, 15 Feb 2007 02:52:55 +0000
Subject: Extending DOMNode
Groups: php.general 
Request: Send a blank email to php-general+get-248895@lists.php.net to get a copy of this message
Hi, I want to add some functionality to all classes derived from DOMNode. I tried: <?php class MyDOMNode extends DOMNode { public $v = 10; function __construct() {} } $dom = new DOMDocument(); $dom->registerNodeClass('DOMNode','MyDOMNode'); $dom->loadXML('<root><a/></root>'); echo $dom->firstChild->v; #<-- not outputs 10 ?> But I get the notice: PHP Notice: Undefined property: DOMElement::$v in ... I want the extension to be valid for all DOM nodes that are derived from DOMNode, such as DOMElement, DOMAttr, DOMNodeList, DOMText, etc... I try not to extend all the classes one by one. How can I do that? -thanks, Eli

« previous php.general (#248895) next »