(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 路徑)
在 include_path 中搜尋檔案。
版本 | 說明 |
---|---|
8.0.0 |
config 和 encoding 現在可以為 null。 |
範例 #1 tidy::parseFile() 範例
<?php
$tidy = new tidy();
$tidy->parseFile('file.html');
$tidy->cleanRepair();
if(!empty($tidy->errorBuffer)) {
echo "發生以下錯誤或警告:\n";
echo $tidy->errorBuffer;
}
?>