3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * What is the DOM Core Version is Supported by PHP DOM? */ $dom = new DOMDocument(); $dom->loadXML('<root/>'); $element = $dom->documentElement; function dom_list_feature(DOMDocument $dom, $feature, array $versions) { echo "$feature Feature is in PHP DOMDocument implementation:\n\n"; $found = []; foreach ($versions as $i => $version) { $result = $dom->implementation->hasFeature($feature, $version); if ($result) { $found[] = $version; } printf(" %d.) $feature %' -5s: %s\n", $i + 1, var_export($version, true), $result ? 'TRUE' : 'FALSE'); } $formatter = new NumberFormatter('en_UK', NumberFormatter::SPELLOUT); $count = ucfirst($formatter->format($found)); printf("\n%s %s versions found%s.\n\n", $count, $feature, $found ? ': ' . implode('; ', $found) : ''); } # Test DOMDocument in PHP Support for DOM-Core Feature # Document Object Model (DOM) <http://www.w3.org/DOM/DOMTR> dom_list_feature($dom, "Core", ['3.0', '2.0', '1.0', '', NULL]); # Test DOMDocument in PHP Support for DOM-XPath Feature # Document Object Model XPath <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html> dom_list_feature($dom, "XPath", ['3.0', '2.0', '1.0', '', NULL]);

preferences:
39.38 ms | 402 KiB | 5 Q