라이브러리
[PHP] DOMDocument::createComment - 새로운 주석 노드 생성
DOMDocument::createComment
DOMDocument::createComment은 DOMDocument 클래스의 메소드 중 하나로, 주어진 문자열을 HTML 주석으로 생성합니다. 이 메소드는 DOMDocument 객체에 새로운 HTML 주석 노드를 추가합니다.
# 사용법
#hostingforum.kr
php
$doc = new DOMDocument();
$comment = $doc->createComment('이 주석은 PHP로 생성되었습니다.');
$doc->appendChild($comment);
echo $doc->saveXML();
# 예제
#hostingforum.kr
php
$doc = new DOMDocument();
$root = $doc->createElement('root');
$doc->appendChild($root);
$comment1 = $doc->createComment('이 주석은 root 노드의 자식입니다.');
$root->appendChild($comment1);
$comment2 = $doc->createComment('이 주석은 root 노드의 자식입니다. (2)');
$root->appendChild($comment2);
echo $doc->saveXML();
# 결과
#hostingforum.kr
xml
<?xml version="1.0"?>
# DOMDocument::createComment의 특징
* 주어진 문자열을 HTML 주석으로 생성합니다.
* DOMDocument 객체에 새로운 HTML 주석 노드를 추가합니다.
* 주석 노드는 DOMDocument 객체의 자식 노드가 될 수 있습니다.
# DOMDocument::createComment의 사용 사례
* HTML 문서에 주석을 추가할 때 사용할 수 있습니다.
* XML 문서에 주석을 추가할 때 사용할 수 있습니다.
* DOMDocument 객체에 새로운 노드를 추가할 때 사용할 수 있습니다.
# 참고 자료
* [DOMDocument::createComment](https://www.php.net/manual/kr/domdocument.createcomment.php)
* [DOMDocument](https://www.php.net/manual/kr/class.domdocument.php)
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.