
XSLTProcessor::transformToXml() 메소드의 반환 타입을 확인하는 방법은 다음과 같습니다.
1. 반환 타입을 확인하기 위해서는 gettype() 함수를 사용할 수 있습니다. 이 함수는 반환 타입을 문자열로 반환합니다.
#hostingforum.kr
php
$xml = $xslt->transformToXml($xml);
echo gettype($xml); // XMLDocument
2. 반환 타입이 XMLDocument인지 확인하기 위해서는 instanceof 연산자를 사용할 수 있습니다.
#hostingforum.kr
php
$xml = $xslt->transformToXml($xml);
if ($xml instanceof DOMDocument) {
echo 'DOMDocument';
} elseif ($xml instanceof Document) {
echo 'Document';
} else {
echo 'XMLDocument';
}
3. 반환 타입이 XMLDocument인지 확인하기 위해서는 is_object() 함수를 사용할 수 있습니다.
#hostingforum.kr
php
$xml = $xslt->transformToXml($xml);
if (is_object($xml)) {
echo 'XMLDocument';
} else {
echo 'Not XMLDocument';
}
위의 코드를 실행하면 반환 타입이 XMLDocument인지, DOMDocument인지, Document인지 확인할 수 있습니다.
위의 예시 코드는 XMLDocument을 반환합니다.
#hostingforum.kr
php
$xslt = new XSLTProcessor();
$xslt->importStyleSheet($xsl);
$xml = $xslt->transformToXml($xml);
echo gettype($xml); // XMLDocument
2025-06-25 06:41