' . $html); . W...">

Php remove invalid characters

I get the following errors when working with $dom->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . $html); .

 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Char 0xD860 out of allowed range in Entity, line: 1 in D:\xampp\xampp\htdocs\xampp\similarity\functions.php on line 438 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Char 0xDEE2 out of allowed range in Entity, line: 1 in D:\xampp\xampp\htdocs\xampp\similarity\functions.php on line 438 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Invalid char in CDATA 0x3 in Entity, line: 1 in D:\xampp\xampp\htdocs\xampp\similarity\functions.php on line 438 

How to configure and remove these "invalid" characters using php?

Andrew

+4
source share
1 answer

not tested, but this should work:

 $buffer = ob_get_clean(); $tidy = new tidy(); $myHTML = $tidy->repairString('<?xml version="1.0" encoding="UTF-8"?>' . $html); $dom->loadHTML($myHTML); 
+1
source

Source: https://habr.com/ru/post/1411471/


All Articles