3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 hydrate(DOMNode $node) { $this->apply($node); } private function apply(DomNode $node) { if (array_key_exists($node->nodeName, $this->callbacks)) { print $callback($node, $this); } else { print $node->nodeName . PHP_EOL; } foreach ($node->childNodes as $child) { $this->apply($child); } } } $hydrator = new Hydrator(); $hydrator->hydrate($doc->documentElement);
Output for 7.1.0 - 7.2.9
soap-env #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 person #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 car #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 phone #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 birth-place #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 address #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 street #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 plz #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 person #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 car #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 phone #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 birth-place #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 address #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 street #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 plz #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 62
Output for 7.0.0 - 7.0.31
Fatal error: Uncaught TypeError: Return value of Hydrator::setCallbacks() must be an instance of void, none returned in /in/tP5H9:47 Stack trace: #0 /in/tP5H9(34): Hydrator->setCallbacks(Array) #1 /in/tP5H9(68): Hydrator->__construct() #2 {main} thrown in /in/tP5H9 on line 47
Process exited with code 255.
Output for hhvm-3.22.0
soap-env #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 person #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 car #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 phone #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 birth-place #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 address #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 street #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 plz #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 person #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 car #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line -1 phone #text #text birth-place #text #text address #text street #text #text plz #text #text #text #text
Output for hhvm-3.21.0 - 3.21.3
soap-env #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 person #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 car #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 phone #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 birth-place #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 address #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 street #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 plz #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 person #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 car #text Warning: Invalid argument supplied for foreach() in /in/tP5H9 on line 64 phone #text #text birth-place #text #text address #text street #text #text plz #text #text #text #text
Output for hhvm-3.20.2
Fatal error: Uncaught TypeError: Value returned from method Hydrator::setCallbacks() must be of type void, null given in /in/tP5H9:-1 Stack trace: #0 /in/tP5H9(-1): Hydrator->setCallbacks() #1 /in/tP5H9(-1): Hydrator->__construct() #2 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.19.2
Fatal error: Uncaught TypeError: Value returned from method Hydrator::setCallbacks() must be of type void, null given in /in/tP5H9:47 Stack trace: #0 /in/tP5H9(34): Hydrator->setCallbacks() #1 /in/tP5H9(68): Hydrator->__construct() #2 {main}
Process exited with code 255.
Output for 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/tP5H9 on line 37
Process exited with code 255.