DOMComment->__construct()
(PHP 5)
DOMComment->__construct() — 新しい DOMComment オブジェクトを作成する
説明
DOMComment
__construct
([ string $value
] )
新しい DOMComment オブジェクトを作成します。 このオブジェクトは読み込み専用です。このオブジェクトをドキュメントに 追加することが可能ですが、ノードがドキュメントと関連付けられるまでは ノードを追加することはできません。書き込み可能なノードを作成するには、 DOMDocument->createComment() を使用します。
パラメータ
- value
-
コメントの値。
例
Example#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> */
?>