Extending DOMNode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux