(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_path からファイルを探します。
tidy::parseFile() は成功時に true
を返します。 tidy_parse_file() は、成功時に新しい tidy インスタンスを返します。 これらのメソッド、関数は、ともに失敗時に false
を返します。
バージョン | 説明 |
---|---|
8.0.0 | config と encoding は、 nullable になりました。 |
例1 tidy::parseFile() の例
<?php
$tidy = new tidy();
$tidy->parseFile('file.html');
$tidy->cleanRepair();
if(!empty($tidy->errorBuffer)) {
echo "The following errors or warnings occurred:\n";
echo $tidy->errorBuffer;
}
?>