(PHP 5, PHP 7, PHP 8, PECL tidy >= 0.5.2)
tidy::parseFile -- tidy_parse_file — 解析文件或URI中的标记
面向对象风格
$filename,$config = null,$encoding = null,$useIncludePath = false过程式风格
$filename,$config = null,$encoding = null,$useIncludePath = false解析给定的文件。
filename如果给出了$filename参数,此函数还将读取该文件并使用该文件初始化对象,其作用类似于tidy_parse_file()。
config$config配置参数可以作为数组或字符串传递。如果传递字符串,则将其解释为配置文件的名称,否则将其解释为选项本身。
有关每个选项的说明,请参阅 » http://api.html-tidy.org/#quick-reference。
encoding$encoding参数设置输入/输出文档的编码。编码的可能值为:ascii、latin0、latin1、raw、utf8、iso2022、mac、win1252、ibm858、utf16、utf16le、utf16be、big5和shiftjis。
useIncludePath在include_path中搜索文件。
| 版本 | 描述 |
|---|---|
| 8.0.0 |
$config和$encoding现在可以为空。 |
示例 #1 tidy::parseFile() 例子
<?php
$tidy = new tidy();
$tidy->parseFile('file.html');
$tidy->cleanRepair();
if(!empty($tidy->errorBuffer)) {
echo "出现以下错误或警告:\n";
echo $tidy->errorBuffer;
}
?>