DOMDocument->saveHTMLFile Dumps the internal document back into a file using HTML formatting &reftitle.description; stringDOMDocument->saveHTMLFile stringfilename Creates an HTML document from the dom representation. This function usually is called after building a new dom document from scratch as in the example below. Creating a simple HTML document header 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); $doc->saveHTMLFile("/tmp/test.hmtl"); ?> ]]> See also DOMDocument->loadHTML(), DOMDocument->loadHTMLFile() and DOMDocument->saveHTML().