PHP | DOMNode isSupported()函数
DOMNode::isSupported()函数是PHP中的一个内置函数,用于检查指定版本是否支持请求的功能。
句法:
bool DOMNode::isSupported( string $feature, string $version )
参数:该函数接受上面提到的两个参数,如下所述:
- $feature:它指定要测试的功能。
- $version:它指定要测试的功能的版本。
返回值:此函数在成功时返回 TRUE,在失败时返回 FALSE。
下面的例子说明了PHP中的DOMNode::isSupported()函数:
示例 1:
isSupported($featureName1, '1.0');
if ($isSupported1) {
echo "Has feature $featureName1 module
";
}
// Write another feature name
$featureName2 = "XML";
// Check if it exists
$isSupported2 = $node1->isSupported($featureName2, '2.0');
if ($isSupported2) {
echo "Has feature $featureName2 module";
}
?>
输出:
Has feature Core module
Has feature XML module
示例 2:
isSupported($featureName1, '1.0');
if (!$isSupported1) {
echo "Doesn't has feature $featureName1 module
";
}
// Write another feature name
$featureName2 = "CSS";
// Check if it exists
$isSupported2 = $node1->isSupported($featureName2, '2.0');
if (!$isSupported2) {
echo "Doesn't has feature $featureName2 module";
}
?>
输出:
Doesn't has feature Events module
Doesn't has feature CSS module
参考: https://www.支持PHP.net/manual/en/domnode.is。 PHP