array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ru', ), 'this' => array ( 0 => 'domcomment.construct.php', 1 => 'DOMComment::__construct', ), 'up' => array ( 0 => 'class.domcomment.php', 1 => 'DOMComment', ), 'prev' => array ( 0 => 'class.domcomment.php', 1 => 'DOMComment', ), 'next' => array ( 0 => 'class.domdocument.php', 1 => 'DOMDocument', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ru', 'path' => 'reference/dom/domcomment/construct.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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> */
?>