<?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
?>