note 117190 added to domdocument.savehtml

From: Date: Wed, 29 Apr 2015 15:49:35 +0000
Subject: note 117190 added to domdocument.savehtml
Groups: php.notes 
Request: Send a blank email to php-notes+get-202394@lists.php.net to get a copy of this message
Tested in PHP 5.2.9-2 and PHP 5.2.17. saveHTML() игнорирует свойство DOMDocument->encoding. Метод saveHTML() сохраняет html-документ в кодировке, которая указана в теге <meta> исходного (загруженного) html-документа. saveHTML() ignores property DOMDocument->encoding. Method saveHTML() saves the html-document encoding, which is specified in the tag <meta> source (downloaded) html-document. Example: file.html. Кодировка файла должна совпадать с указанной в теге <meta>. The encoding of the file must match the specified tag <meta>. <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>Russian language</title></head> <body>Русский язык</body></html> <?php error_reporting(-1); $document=new domDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace=false; $document->loadHTMLFile('file.html'); $document->formatOutput=true; $document->encoding='UTF-8'; $htm=$document->saveHTML(); echo"Записано байт. Recorded bytes: ".file_put_contents('file_new.html', $htm); ?> file_new.html будет в кодировке Windows-1251 (НЕ в UTF-8). file_new.html will be encoded in Windows-1251 (not in UTF-8). saveHTML() и file_put_contents() позволяют преодолеть недостаток метода saveHTMLFile(). Смотрите мой комментарий к методу saveHTMLFile(). saveHTML() and file_put_contents() allows you to overcome the lack of a method saveHTMLFile(). See my comment on the method saveHTMLFile(). http://php.net/manual/ru/domdocument.savehtmlfile.php ---- Server IP: 72.52.91.14 Probable Submitter: 178.216.123.184 ---- Manual Page -- http://php.net/manual/en/domdocument.savehtml.php Edit -- https://master.php.net/note/edit/117190 Del: integrated -- https://master.php.net/note/delete/117190/integrated Del: useless -- https://master.php.net/note/delete/117190/useless Del: bad code -- https://master.php.net/note/delete/117190/bad+code Del: spam -- https://master.php.net/note/delete/117190/spam Del: non-english -- https://master.php.net/note/delete/117190/non-english Del: in docs -- https://master.php.net/note/delete/117190/in+docs Del: other reasons-- https://master.php.net/note/delete/117190 Reject -- https://master.php.net/note/reject/117190 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202394) next »