3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $root = new DOMDocument(); $root->formatOutput = true; $root->loadXML('<article id=""></article>'); for($i=0;$i<=300;$i++){ $node = new DOMDocument(); $node->loadXML('<section id="'.$i.'" data-country="DEU"><h1>Überschrift</h1><h2>Überschrift2</h2><p>Content</p></section>'); $xpath = new DOMXPath($node); $query = '//section'; $entries=$xpath->query($query); $entries->removeAttribute('data-country'); $entries->setAttribute("data-country", substr(md5(rand()),0,7)); $query = '//h1'; $entries=$xpath->query($query); if($entries->length===1){ $entries->item(0)->nodeValue = ""; $entries->item(0)->appendChild($node->createTextNode("Text ".$i)); } $query = '//h2'; $entries=$xpath->query($query); if($entries->length===1){ $entries->item(0)->nodeValue = ""; $entries->item(0)->appendChild($node->createTextNode(md5("Text ".$i))); } $node = $root->importNode($node->documentElement, true); $root->documentElement->appendChild($node); } print $root->saveXML();
based on BfSs4
Output for 7.0.0 - 7.3.1
Fatal error: Uncaught Error: Call to undefined method DOMNodeList::removeAttribute() in /in/JdsF1:15 Stack trace: #0 {main} thrown in /in/JdsF1 on line 15
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Call to undefined method DOMNodeList::removeAttribute() in /in/JdsF1:15 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Call to undefined method DOMNodeList::removeAttribute() in /in/JdsF1 on line 15
Process exited with code 255.