DOM DOMProcessingInstruction::__construct

(PHP 5, PHP 7, PHP 8)

DOMProcessingInstruction::__construct — 새로운 DOMProcessingInstruction 객체를 생성합니다.


설명

public DOMProcessingInstruction::__construct(string $name, string $value = "")

DOMProcessingInstruction 개체를 만듭니다. 이 개체는 읽기 전용입니다. 문서에 추가될 수 있지만 노드가 문서와 연결될 때까지 이 노드에 추가 노드가 추가되지 않을 수 있습니다. 쓰기 가능한 노드를 만들려면 DOMDocument::createProcessingInstruction을 사용합니다.


매개변수

name
처리 명령의 태그 이름입니다.
value
처리 명령의 값입니다.

Examples

예제 #1DOMProcessingInstruction 객체 생성

                  
<?php

$dom = new DOMDocument('1.0', 'UTF-8');
$html = $dom->appendChild(new DOMElement('html'));
$body = $html->appendChild(new DOMElement('body'));
$pinode = new DOMProcessingInstruction('php', 'echo "Hello World"; ');
$body->appendChild($pinode);
echo $dom->saveXML();

?>
                  
                

위의 예는 다음을 출력합니다.

<?xml version="1.0" encoding="UTF-8"?>
<html><body><?php echo "Hello World"; ?></body></html>
                

기타