note 101854 added to domdocument.savehtmlfile
| From: | deep42thouSPAMght42 at y_a_h_o_o dot com | Date: | Fri, 14 Jan 2011 11:46:02 +0000 |
| Subject: | note 101854 added to domdocument.savehtmlfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175740@lists.php.net to get a copy of this message | ||
I foolishly assumed that this function was equivalent to
<?php
file_put_contents($filename, $document->saveHTML());
?>
but there are differences in the generated HTML:
<?php
$doc = new DOMDocument();
$doc->loadHTML(
'<html><head><title>Test</title></head><body></body></html>'
);
$doc->encoding = 'iso-8859-1';
echo $doc->saveHTML();
#<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
#<html>
#<head><title>Test</title></head>
#<body></body>
#</html>
$doc->saveHTMLFile('output.html');
#<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
#<html><head><meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"><title>Test</title></head><body></body></html>
?>
Note that saveHTMLFile() adds a UTF-8 meta tag despite the ISO-8859-1 document encoding.
----
Server IP: 69.147.83.197
Probable Submitter: 98.119.228.242
----
Manual Page -- http://www.php.net/manual/en/domdocument.savehtmlfile.php
Edit -- https://master.php.net/note/edit/101854
Del: integrated -- https://master.php.net/note/delete/101854/integrated
Del: useless -- https://master.php.net/note/delete/101854/useless
Del: bad code -- https://master.php.net/note/delete/101854/bad+code
Del: spam -- https://master.php.net/note/delete/101854/spam
Del: non-english -- https://master.php.net/note/delete/101854/non-english
Del: in docs -- https://master.php.net/note/delete/101854/in+docs
Del: other reasons-- https://master.php.net/note/delete/101854
Reject -- https://master.php.net/note/reject/101854
Search -- https://master.php.net/manage/user-notes.php