使用DOMDocument进行html修复

$htmlStr="<p>1111</p>";
$doc = new DOMDocument();
$doc->loadHTML(mb_convert_encoding($str, 'HTML-ENTITIES','UTF-8'));
//获取html
$html= $doc->saveHTML();
//获取body
$body= $doc->saveHTML($doc->getElementsByTagName('body')->item(0));