tidy_repair_file
(PHP 5, PECL tidy:0.7-1.2)
tidy_repair_file — ファイルを修正し、それを文字列として返す
説明
string tidy_repair_file
( string $filename
[, mixed $config
[, string $encoding
[, bool $use_include_path
]]] )
この関数は、与えられたファイルを修正し、それを文字列として返します。
config パラメータは、配列または 文字列として指定することができます。文字列として指定した場合には設定ファイルの名前として解釈され、 そうでない場合はオプション自体として解釈されます。各オプションに関する説明については、 » https://tidy.sourceforge.net/docs/quickref.html を参照してください。
encoding パラメータは、文書を入力/出力する際のエンコーディングを 設定します。encoding には次の値を使用可能です。 ascii, latin1, raw, utf8, iso2022, mac, win1252, utf16le, utf16be, utf16, big5, shiftjis
Example#1 tidy_repair_file() の例
<?php
$file = 'file.html';
$repaired = tidy_repair_file($file);
rename($file, $file . '.bak');
file_put_contents($file, $repaired);
?>
注意: オプションのパラメータ config_options と enconding は Tidy 2.0 で追加されました。
tidy_parse_file(), tidy_parse_string(), tidy_repair_string() も参照ください。