|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-01-26 21:35 UTC] work at timothytown dot com
Description: ------------ The source in the PHP dom extension causes the LIBXML_NOWARNING flag to be ignored when loading html through DOMDocument. Problem is in ext/dom/document.c of PHP source, in the dom_load_html method. Calling htmlCtxtUseOptions with HTML_PARSE_NOWARNING causes the warning handlers to be unregistered (set to NULL). But the PHP code then proceeds to install its own handlers unconditionally, rendering the flag useless. see stackoverflow http://stackoverflow.com/questions/41860683/libxml-htmlparsedocument-ignoring-htmlparseoption-flags Test script: --------------- $doc=new DOMDocument(); $doc->loadHTML("<tagthatthrowswarning>HI</tagthatthrowswarning>", LIBXML_NOWARNING); echo $doc->saveHTML(); Expected result: ---------------- expected output no warnings output. Actual result: -------------- E_WARNING : type 2 -- DOMDocument::loadHTML(): Tag tagthatthrowswarning invalid in Entity, line: 1 -- at line 4 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
Why is this still producing an error? $ cat html.php <?php $doc = new DOMDocument(); $doc->loadHTML('<tagthatthrowswarn>HI</tagthatthrowswarn>', LIBXML_NOWARNING); $ php -v PHP 7.3.7 (cli) (built: Jul 21 2019 18:10:35) ( NTS ) $ php html.php PHP Warning: DOMDocument::loadHTML(): Tag tagthatthrowswarn invalid in Entity, line: 1 in /Desktop/html.php on line 3