(PHP 5, PHP 7, PHP 8, PECL tidy >= 0.7.0)
tidy::repairFile -- tidy_repair_file — 修复文件并将其作为字符串返回
面向对象风格
$filename,$config = null,$encoding = null,$useIncludePath = false过程化风格
$filename,$config = null,$encoding = null,$useIncludePath = false修复给定的文件并将其作为字符串返回。
filename要修复的文件。
configconfig 参数可以作为数组或字符串传递。如果传递字符串,则将其解释为配置文件的名称,否则将其解释为选项本身。
请查看 http://tidy.sourceforge.net/docs/quickref.html 以了解每个选项的说明。
encodingencoding 参数设置输入/输出文档的编码。编码的可能值为:ascii、latin0、latin1、raw、utf8、iso2022、mac、win1252、ibm858、utf16、utf16le、utf16be、big5 和 shiftjis。
useIncludePath在 include_path 中搜索文件。
返回修复后的内容作为字符串,或者在失败时返回 false。
| 版本 | 描述 |
|---|---|
| 8.0.0 | tidy::repairFile() 现在是一个静态方法。 |
| 8.0.0 |
config 和 encoding 现在可以为 null。 |
示例 #1 tidy::repairFile() 示例
<?php
$file = 'file.html';
$tidy = new tidy();
$repaired = $tidy->repairfile($file);
rename($file, $file . '.bak');
file_put_contents($file, $repaired);
?>