Php/docs/domcomment.construct

提供:Dev Guides
< Php
2020年12月14日 (月) 12:28時点におけるNotes (トーク | 投稿記録)による版 (autoload)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

DOMComment::__construct

(PHP 5, PHP 7)

DOMComment::__construct 新しい DOMComment オブジェクトを作成する


説明

public DOMComment::__construct ([ string $value ] )

新しい DOMComment オブジェクトを作成します。 このオブジェクトは読み込み専用です。このオブジェクトをドキュメントに 追加することが可能ですが、ノードがドキュメントと関連付けられるまでは ノードを追加することはできません。書き込み可能なノードを作成するには、 DOMDocument::createComment を使用します。


パラメータ

value
コメントの値。


例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> */?>

参考