3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo() { global $d; $d = new DOMDocument; $c = $d->createDocumentFragment(); $g = $d->createElement('fiz', 'buz'); $h = $d->createElement('red', 'xen'); $c->appendChild($g); $c->appendChild($h); return $c->childNodes; } foreach (foo() as $x) { var_dump($x->nodeValue); } var_dump($x->nodeValue); var_dump(get_class($d));
based on ALmJ6
Output for 5.2.6 - 7.2.0
string(3) "buz" string(3) "xen" Warning: Couldn't fetch DOMElement. Node no longer exists in /in/qa6EP on line 19 Notice: Undefined property: DOMElement::$nodeValue in /in/qa6EP on line 19 NULL string(11) "DOMDocument"
Output for 5.1.3 - 5.2.5
string(3) "buz" string(3) "xen" Warning: Couldn't fetch DOMElement. Node no longer exists in /in/qa6EP on line 19 Notice: Undefined property: DOMElement::$nodeValue in /in/qa6EP on line 19 NULL string(11) "DOMDocument"
Output for 5.0.0 - 5.1.2
string(3) "buz" string(3) "xen" Notice: Undefined property: DOMElement::$nodeValue in /in/qa6EP on line 19 NULL string(11) "DOMDocument"
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/qa6EP on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/qa6EP on line 5