The DOMComment class
(PHP 5, PHP 7, PHP 8)
简介
Represents comment nodes, characters delimited by <!--
and -->
.
类摘要
/* 继承的常量 */
/* 继承的属性 */
/* 方法 */
/* 继承的方法 */
public DOMNode::C14N(
bool
bool
?array
?array
): string|false
}bool
$exclusive
= false
,bool
$withComments
= false
,?array
$xpath
= null
,?array
$nsPrefixes
= null
): string|false
目录
- DOMComment::__construct — Creates a new DOMComment object
+添加备注
用户贡献的备注 1 note
npelov at croler dot net ¶
3 years ago
Note that textContent property of a comment is not entity decoded, it is decoded in DOMElement::textContent :
<?php
$xml = new DOMDocument();
$xml->loadXML('<?xml version="1.0" encoding="utf-8"?>
<configuration version="2">
<!-- test --> -->
test -->
</configuration>'
);
$xpath = new DOMXPath($xml);
$comments = $xpath->query('//comment()');
$elements = $xpath->query('//configuration');
echo $comments[0]->textContent;
// result: test -->
echo $elements[0]->textContent;
// result: test -->
?>