PHP DOM Extension has the Document Object Model (Core) Level 1 feature. You can test for features that are implemented with a helper method and then testing for features and versions, here a summary for four features:
- One Core versions found:
'1.0'
.
- Four XML versions found:
'2.0'; '1.0'; ''; NULL
.
- Zero HTML versions found.
- Zero XHTML versions found.
- Zero XPath versions found.
This result combine with the specs is puzzeling if not esoteric. The Core Feature in Level 1.0 requires to return TRUE
as well for a non-specified version (here: for ''
and NULL
), but as the results show, it does not. So even DOM Core Level 1 is announced as feature, it's also broken.
Also the XML Feature can not be level 2.0 if the Core feature of level 2.0 is not supported - and this is the case here, Core Level 2.0 is not a supported feature.
Features in DOM (source):

Exemplary Output of my example script:
Core Feature is in PHP DOMDocument implementation:
1.) Core '3.0': FALSE
2.) Core '2.0': FALSE
3.) Core '1.0': TRUE
4.) Core '' : FALSE
5.) Core NULL : FALSE
One Core versions found: '1.0'.
XML Feature is in PHP DOMDocument implementation:
1.) XML '3.0': FALSE
2.) XML '2.0': TRUE
3.) XML '1.0': TRUE
4.) XML '' : TRUE
5.) XML NULL : TRUE
Four XML versions found: '2.0'; '1.0'; ''; NULL.
HTML Feature is in PHP DOMDocument implementation:
1.) HTML '3.0': FALSE
2.) HTML '2.0': FALSE
3.) HTML '1.0': FALSE
4.) HTML '' : FALSE
5.) HTML NULL : FALSE
Zero HTML versions found.
XHTML Feature is in PHP DOMDocument implementation:
1.) XHTML '3.0': FALSE
2.) XHTML '2.0': FALSE
3.) XHTML '1.0': FALSE
4.) XHTML '' : FALSE
5.) XHTML NULL : FALSE
Zero XHTML versions found.
XPath Feature is in PHP DOMDocument implementation:
1.) XPath '3.0': FALSE
2.) XPath '2.0': FALSE
3.) XPath '1.0': FALSE
4.) XPath '' : FALSE
5.) XPath NULL : FALSE
Zero XPath versions found.
Example script:
<?php
/**
* What is the DOM Core Version is Supported by PHP DOM?
* @link http://stackoverflow.com/a/17340953/367456
*/
$dom = new DOMDocument();
$dom->loadXML('<root/>');
$versionsArray = ['3.0', '2.0', '1.0', '', NULL];
$features = [
# Document Object Model (DOM) <http://www.w3.org/DOM/DOMTR>
'Core' => $versionsArray,
# Document Object Model (DOM) <http://www.w3.org/DOM/DOMTR>
'XML' => $versionsArray,
# Document Object Model (DOM) Level 2 HTML Specification <http://www.w3.org/TR/DOM-Level-2-HTML/>
'HTML' => $versionsArray,
'XHTML' => $versionsArray,
# Document Object Model XPath <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html>
"XPath" => $versionsArray,
];
const DISPLAY_TITLE = 1;
const DISPLAY_DETAILS = 2;
const DISPLAY_SUMMARY = 4;
const DISPLAY_ALL = 7;
dom_list_features($dom, $features);
function dom_list_features(DOMDocument $dom, array $features, $display = DISPLAY_ALL) {
foreach ($features as $feature => $versions) {
dom_list_feature($dom, $feature, $versions, $display);
}
}
function dom_list_feature(DOMDocument $dom, $feature, array $versions, $display) {
if ($display & DISPLAY_TITLE) {
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;
}
if ($display & DISPLAY_DETAILS) {
printf(" %d.) $feature %' -5s: %s\n", $i + 1, var_export($version, true), $result ? 'TRUE' : 'FALSE');
}
}
if ($display & DISPLAY_DETAILS) {
echo "\n";
}
$formatter = new NumberFormatter('en_UK', NumberFormatter::SPELLOUT);
$count = ucfirst($formatter->format(count($found)));
$found = array_map(function ($v) {
return var_export($v, TRUE);
}, $found);
if ($display & DISPLAY_SUMMARY) {
printf("%s %s versions found%s.\n\n", $count, $feature, $found ? ': ' . implode('; ', $found) : '');
}
}