tidy::repairFile()
(PHP 5, PHP 7, PECL tidy >= 0.7.0)
修复文件并将其作为字符串返回
说明
面向对象风格public tidy::repairFile(string $filename[,mixed $config[,string $encoding[,bool $use_include_path=FALSE
]]]): string
过程化风格
tidy_repair_file(string $filename[,mixed $config[,string $encoding[,bool $use_include_path=FALSE
]]]): string
参数
- $filename:如果给定了$filename参数,此函数还将读取该文件并用该文件初始化对象,其作用如tidy_parse_file()
- $config:配置选项可以作为数组或字符串传递。如果传递字符串,则将其解释为配置文件的名称,否则,将其解释为选项本身.
- $encoding:编码参数设置输入/输出文档的编码。可能的编码值是:ascii,latin0,latin1,raw,utf8,iso2022,mac,win1252,ibm858,utf16,utf16le,utf16be,big5, andshiftjis
- $use_include_path:在包含路径中搜索文件。
返回值
将修复的内容作为字符串返回。
范例
<?php $file = 'file.html'; $tidy = new tidy(); $repaired = $tidy->repairfile($file); rename($file, $file . '.bak'); file_put_contents($file, $repaired); ?>
参见
- tidy::parseFile() 分析文件或URI中的标记
- tidy::parseString() 分析存储在字符串中的文档
- tidy::repairString() 使用可选提供的配置文件修复字符串