Extending DOMNode
- From: eli.hen@xxxxxxxxx (Eli)
- Date: Thu, 15 Feb 2007 04:52:55 +0200
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
.
- Follow-Ups:
- Re: Extending DOMNode
- From: Rob Richards
- Re: Extending DOMNode
- Prev by Date: Re: PDFLib Broke on Windows PHP Binaries -- need new binary
- Next by Date: Session problems with 4.4.5?
- Previous by thread: php/mysql syntax help
- Next by thread: Re: Extending DOMNode
- Index(es):