3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0" encoding="utf-8" ?> <soap-env> <person name="Max Musterman"> <car marke="BMW" kennung="i8"/> <phone name="iPhone">9</phone> <birth-place>Hamburg</birth-place> <address> <street>Hauptstraße 1</street> <plz>245698</plz> </address> </person> <person name="Dr. Dolittle"> <car marke="Audi" kennung="A3"/> <phone name="Sony">Xperia Z3</phone> <birth-place>München</birth-place> <address> <street>Partkstraße</street> <plz>365494</plz> </address> </person> </soap-env>'; $doc = new DomDocument('1.0', 'utf-8'); $doc->loadXml($xml); final class Hydrator { private $callbacks = []; public function __construct(array $callbacks = []) { $this->setCallbacks($callbacks); } public function setCallback(string $nodeName, callable $callback): void { $this->callbacks[$nodeName] = $callback; } public function setCallbacks(array $callbacks): void { foreach ($callbacks as $nodeName => $callback) { $this->setCallback($nodeName, $callback); } } public function hydrateDocument(DOMDocument $document) { $this->hdrateNode($document->documentElement); } public function hydrateNode(DOMNode $node) { $this->apply($node); if ($node->hasChildNodes()) { $this->traverseChildren($node); } } private function traverseChildren(DOMNode $node) { foreach ($node->childNodes as $child) { $this->hydrate($child); } } private function apply(DomNode $node) { if (array_key_exists($node->nodeName, $this->callbacks)) { print $callback($node, $this); } else { print $node->nodeName . PHP_EOL; } } } $hydrator = new Hydrator(); $hydrator->hydrateDocument($doc);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined method Hydrator::hdrateNode() in /in/dQM6g:51 Stack trace: #0 /in/dQM6g(81): Hydrator->hydrateDocument(Object(DOMDocument)) #1 {main} thrown in /in/dQM6g on line 51
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.81 ms | 401 KiB | 8 Q