DOMNode::isSupported()函数是PHP中的内置函数,用于检查指定版本是否支持所要求的函数。
用法:
bool DOMNode::isSupported( string $feature, string $version )
参数:该函数接受上述和以下描述的两个参数:
- $feature:它指定要测试的函数。
- $version:它指定要测试的函数的版本。
返回值:如果成功,则此函数返回TRUE;如果失败,则返回FALSE。
以下示例说明了PHP中的DOMNode::isSupported()函数:
范例1:
<?php
// Write the feature name
$featureName1 = "Core";
// Check if it exists
$node1 = new DOMNode();
$isSupported1 = $node1->isSupported($featureName1, '1.0');
if ($isSupported1) {
echo "Has feature $featureName1 module<br>";
}
// 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:
<?php
// Write the feature name
$featureName1 = "Events";
// Check if it exists
$node1 = new DOMNode();
$isSupported1 = $node1->isSupported($featureName1, '1.0');
if (!$isSupported1) {
echo "Doesn't has feature $featureName1 module<br>";
}
// 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.issupported.php
相关用法
- PHP DOMNode getNodePath()用法及代码示例
- PHP DOMNode getLineNo()用法及代码示例
- PHP DOMNode isDefaultNamespace()用法及代码示例
- PHP DOMNode hasAttributes()用法及代码示例
- PHP DOMNode appendChild()用法及代码示例
- PHP DOMNode C14N()用法及代码示例
- PHP DOMNode cloneNode()用法及代码示例
- PHP DOMNode C14NFile()用法及代码示例
- HTML DOM Node isSupported()用法及代码示例
- PHP min( )用法及代码示例
- d3.js d3.set.add()用法及代码示例
- p5.js value()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | DOMNode isSupported() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。