本文介绍了PHP删除无效的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 $ 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
如何使用php定位和删除那些无效字符?
How do I target and remove those "invalid" charaters using php?
Andrej
推荐答案
未经测试,但这应该可行:
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);
这篇关于PHP删除无效的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!