21,894
社区成员




$buffer = "<html>
<head>
<title>test</title>
</head>
<body>
<div>
<p>indent: 代码缩进,可选auto,yes,no,在php中,填auto将会被默认为yes,所以,此项在php中可分别用2,1,0来表示,2表示auto,1表示yes,0表示no不开启。wrap:换行,用0表示不换行。output-xhtml:输出xhtml格式文档。
</p>
</div>
</div>
</body>
</html>";
$outstr = tidy_repair_string($buffer, array("input-encoding"=>"utf8","output-encoding"=>"utf8"), "utf8");
echo $outstr;
<?php
$buffer = "<html>
<head>
<title>test</title>
</head>
<body>
<div>
<p>indent: 代码缩进,可选auto,yes,no,在php中,填auto将会被默认为yes</p>
</div>
</div>
</body>
</html>";
$outstr = tidy_repair_string($buffer, array('output-xhtml' => true), 'utf8');
echo $outstr;
?>
$outstr = tidy_repair_string($buffer, array('output-xhtml' => true), 'utf8'); //这样呢
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<?php
header("Content-Type: text/html; charset=utf8");
$buffer = "<html>
<head>
<title>test</title>
</head>
<body>
<div>
<p>indent: 代码缩进,可选auto,yes,no,在php中,填auto将会被默认为yes</p>
</div>
</div>
</body>
</html>";
$outstr = tidy_repair_string($buffer, array('char-encoding'=>'utf8'));
echo $outstr;
?>
</html>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>test</title>
</head>
<body>
<div>
<p>indent:
´úÂëËõ½ø£¬¿ÉÑ¡auto,yes,no£¬ÔÚphpÖУ¬Ìîauto½«»á±»Ä¬ÈÏΪyes,ËùÒÔ£¬´ËÏîÔÚphpÖпɷֱðÓÃ2,1,0À´±íʾ£¬2±íʾauto,1±íʾyes,0±íʾno²»¿ªÆô¡£wrap:»»ÐУ¬ÓÃ0±íʾ²»»»ÐС£output-xhtml£ºÊä³öxhtml¸ñʽÎĵµ¡£</p>
</div>
</body>
</html>
$outstr = tidy_repair_string($buffer, array('char-encoding' => 'utf8')); //抱歉,上面漏掉个括号
$outstr = tidy_repair_string($buffer, array('char-encoding' => 'utf8'); //这样呢?