array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), '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' => 'fr', '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 — Crée un nouvel objet DOMComment
Crée un nouvel objet DOMComment. Cet objet est en lecture seule. Il peut être ajouté à un document, mais les nœuds additionnels ne peuvent pas être ajoutés à ce nœud tant que ce nœud n'est pas associé à un document. Pour créer un nœud accessible en écriture, utilisez DOMDocument::createComment.
data
La valeur du commentaire.
Exemple #1 Création d'un nouveau 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> */
?>