라이브러리
[PHP] DOMProcessingInstruction::__construct - 새 DOMProcessingInstruction 객체를 생성합니다.
DOMProcessingInstruction::__construct
`DOMProcessingInstruction::__construct`는 DOMProcessingInstruction 클래스의 생성자입니다. 이 메소드는 DOMProcessingInstruction 객체를 생성하고, 인수로 전달된 내용을 객체의 내용으로 설정합니다.
생성자 인수
생성자 인수는 2개입니다.
- `$target`: 처리 지시문의 타겟을 지정합니다. 예를 들어, `<?xml-stylesheet` 타겟은 XML 스타일 시트를 지정합니다.
- `$data`: 처리 지시문의 내용을 지정합니다.
예제
#hostingforum.kr
php
// DOMProcessingInstruction 객체를 생성합니다.
$instruction = new DOMProcessingInstruction('xml-stylesheet', 'href="style.css" type="text/css"');
// DOMDocument 객체를 생성합니다.
$doc = new DOMDocument();
$doc->appendChild($instruction);
// DOMDocument 객체를 출력합니다.
echo $doc->saveXML();
위 예제에서는 `xml-stylesheet` 타겟과 `href="style.css" type="text/css"` 내용을 가진 DOMProcessingInstruction 객체를 생성하고, DOMDocument 객체에 추가합니다. 그 후 DOMDocument 객체를 출력합니다.
출력 결과
#hostingforum.kr
xml
<?xml version="1.0"?>
<?xml-stylesheet href="style.css" type="text/css"?>
위 예제는 XML 스타일 시트를 지정하는 처리 지시문을 생성하고, DOMDocument 객체에 추가하는 예제입니다.
참고
- `DOMProcessingInstruction` 클래스는 DOMDocument 객체의 자식 노드로 추가할 수 있습니다.
- `DOMProcessingInstruction` 객체의 `target` 속성을 통해 타겟을 가져오거나 설정할 수 있습니다.
- `DOMProcessingInstruction` 객체의 `data` 속성을 통해 내용을 가져오거나 설정할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.