(PHP 5, PHP 7, PHP 8)
DOMImplementation::hasFeature — 测试 DOM 实现是否实现了特定功能
feature
要测试的功能。
version
要测试的 feature
的版本号。在级别 2 中,这可以是 2.0
或 1.0
。
示例 #1 测试您的 DOM 实现
<?php
$features = array(
'Core' => 'Core module',
'XML' => 'XML module',
'HTML' => 'HTML module',
'Views' => 'Views module',
'Stylesheets' => 'Style Sheets module',
'CSS' => 'CSS module',
'CSS2' => 'CSS2 module',
'Events' => 'Events module',
'UIEvents' => 'User interface Events module',
'MouseEvents' => 'Mouse Events module',
'MutationEvents' => 'Mutation Events module',
'HTMLEvents' => 'HTML Events module',
'Range' => 'Range module',
'Traversal' => 'Traversal module'
);
$implementation = new DOMImplementation;
foreach ($features as $key => $name) {
if ($implementation->hasFeature($key, '2.0')) {
echo "Has feature $name\n";
} else {
echo "Missing feature $name\n";
}
}
?>