(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
要修復的檔案。
config
參數 config
可以傳遞為陣列或字串。如果傳遞字串,則將其解釋為配置檔案的名稱;否則,將其解釋為選項本身。
請查看 http://tidy.sourceforge.net/docs/quickref.html 以取得每個選項的說明。
encoding
參數 encoding
設定輸入/輸出文件的編碼。編碼的可能值為: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);
?>