<?php
ob_start(); //开始捕获HTML代码(包含标签错误的)
?>
<html>
<head>
<title>What</title>
</head>
<body>
<p>error</i>
<div>
<ul>
<li>aaaaaaa
</body>
</html>
<?php
$buffer = ob_get_clean(); //捕获结束,以上内容不会被输出!
$tidy = new tidy();
$clean = $tidy->repairString($buffer); //修复HTML
echo $clean; //重新输出修复了的HTML
?>