tidy::repairFile
tidy_repair_file
(PHP 5, PHP 7, PECL tidy >= 0.7.0)
tidy::repairFile -- tidy_repair_file — ファイルを修正し、それを文字列として返す
説明
オブジェクト指向型
public static tidy::repairFile
( string $filename
[, array|string|null $config
= null
[, string|null $encoding
= null
[, bool $useIncludePath
= false
]]] ) : string|false
手続き型
tidy_repair_file
( string $filename
[, array|string|null $config
= null
[, string|null $encoding
= null
[, bool $useIncludePath
= false
]]] ) : string|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 からファイルを探します。
返り値
修正した内容を文字列で返します。
例
例1 tidy::repairFile() の例
<?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() - 別途提供される設定ファイルを使用して文字列を修正する