PHP | DOMImplementation hasFeature()函数
DOMImplementation::hasFeature()函数是PHP中的一个内置函数,用于测试 DOM 实现是否实现了特定功能。
句法:
bool DOMImplementation::hasFeature( string $feature, string $version )
参数:该函数接受上面提到的两个参数,如下所述:
- $feature:它指定要测试的功能。
- $version:它指定要测试的功能的版本号。
返回值:此函数在成功时返回 TRUE,在失败时返回 FALSE。
异常:此函数在出错时抛出E_STRICT异常。
下面的例子说明了PHP中的DOMImplementation::hasFeature()函数:
示例 1:
";
}
// Write another feature name
$featureName2 = "XML";
// Check if it exists
$hasFeature2 =
DOMImplementation::hasFeature($featureName2, '2.0');
if ($hasFeature2) {
echo "Has feature $featureName2 module
";
}
?>
输出:
Has feature Core module
Has feature XML module
示例 2:
";
}
// Write another feature name
$featureName2 = "CSS";
// Check if it doesn't exists
$hasFeature2 =
DOMImplementation::hasFeature($featureName2, '2.0');
if (!$hasFeature2) {
echo "Doesn't have feature $featureName2 module.
";
}
?>
输出:
Doesn't have feature Events module.
Doesn't have feature CSS module.
参考: https://www. PHP.net/manual/en/domimplementation.hasfeature。 PHP