<?php
namespace DOMWorks;
use \DOMNode,
\DOMElement,
\DOMDocument;
class Node extends DOMNode
{
public function foo()
{
echo "Yay for foo!";
}
}
class Element extends DOMElement
{
public function bar()
{
echo "Yay for bar!";
}
}
class Document extends DOMDocument
{
public function __construct($version = null, $encoding = null)
{
parent::__construct($version, $encoding);
$this->registerNodeClass('\DOMElement', __NAMESPACE__ . '\Element');
$this->registerNodeClass('\DOMNode', __NAMESPACE__ . '\Node');
}
// methods...
}
$doc = new Document;
$doc->foo();
Deprecated: DOMDocument::__construct(): Passing null to parameter #1 ($version) of type string is deprecated in /in/ScD0n on line 29
Deprecated: DOMDocument::__construct(): Passing null to parameter #2 ($encoding) of type string is deprecated in /in/ScD0n on line 29
Fatal error: Uncaught Error: Call to undefined method DOMWorks\Document::foo() in /in/ScD0n:38
Stack trace:
#0 {main}
thrown in /in/ScD0n on line 38
Process exited with code 255.
Fatal error: Uncaught Error: Call to undefined method DOMWorks\Document::foo() in /in/ScD0n:38
Stack trace:
#0 {main}
thrown in /in/ScD0n on line 38
Process exited with code 255.