(PHP 5, PHP 7, PHP 8)
DOMComment::__construct — 建立新的 DOMComment 物件
建立新的 DOMComment 物件。此物件是唯讀的。它可以附加到文件,但在節點與文件關聯之前,不能將其他節點附加到此節點。要建立可寫入的節點,請使用 DOMDocument::createComment。
data
註釋的值。
範例 #1 建立新的 DOMComment
<?php
$dom = new DOMDocument('1.0', 'iso-8859-1');
$element = $dom->appendChild(new DOMElement('root'));
$comment = $element->appendChild(new DOMComment('root comment'));
echo $dom->saveXML(); /* <?xml version="1.0" encoding="iso-8859-1"?><root><!--root comment--></root> */
?>