DOM DOMComment::__construct
(PHP 5, PHP 7, PHP 8)
DOMComment::__construct — 새로운 DOMComment 객체를 생성합니다.
설명
public DOMComment::__construct(string $data
= "")
새로운 DOMComment 객체를 생성합니다. 이 개체는 읽기 전용입니다. 문서에 추가될 수 있지만 노드가 문서와 연결될 때까지 이 노드에 추가 노드가 추가되지 않을 수 있습니다. 쓰기 가능한 노드를 만들려면 DOMDocument::createComment를 사용하십시오.
매개변수
data
- 주석의 값입니다.
Examples
예제 #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> */
?>
기타
- DOMDocument::createComment() - 새 댓글 노드 만들기