DOMComment::__construct

(PHP 5, PHP 7, PHP 8)

DOMComment::__construct Создаёт новый экземпляр класса DOMComment

Описание

public DOMComment::__construct(string $data = "")

Создаёт новый объект класса 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> */

?>

Смотрите также

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top