DOM DOMDocument::saveHTMLFile

(PHP 5, PHP 7, PHP 8)

DOMDocument::saveHTMLFile — HTML 형식을 사용하여 내부 문서를 파일로 덤프합니다.


설명

public DOMDocument::saveHTMLFile(string $filename): int|false

DOM 표현에서 HTML 문서를 만듭니다. 이 함수는 일반적으로 아래 예제와 같이 처음부터 새 dom 문서를 빌드한 후 호출됩니다.


매개변수

filename
저장된 HTML 문서의 경로입니다.

반환 값

쓴 바이트 수를 반환하거나 오류가 발생한 경우 false를 반환합니다.


Examples

예제 #1 HTML 트리를 파일로 저장

                  
<?php

$doc = new DOMDocument('1.0');
// we want a nice output
$doc->formatOutput = true;

$root = $doc->createElement('html');
$root = $doc->appendChild($root);

$head = $doc->createElement('head');
$head = $root->appendChild($head);

$title = $doc->createElement('title');
$title = $head->appendChild($title);

$text = $doc->createTextNode('This is the title');
$text = $title->appendChild($text);

echo 'Wrote: ' . $doc->saveHTMLFile("/tmp/test.html") . ' bytes'; // Wrote: 129 bytes

?>
                  
                

기타