tidy
PHP Manual

tidy::parseFile

tidy_parse_file

(PHP 5, PHP 7, PECL tidy >= 0.5.2)

tidy::parseFile -- tidy_parse_file — ファイルまたは URI にあるマークアップをパースする

説明

オブジェクト指向型

bool tidy::parseFile ( string $filename [, mixed $config [, string $encoding [, bool $use_include_path = false ]]] )

手続き型

tidy tidy_parse_file ( string $filename [, mixed $config [, string $encoding [, bool $use_include_path = false ]]] )

与えられたファイルをパースします。

パラメータ

filename

もし filename パラメータが与えられた場合、 この関数はファイルを読み込み、tidy_parse_file() のように実行してファイルに基づいたオブジェクトを初期化します。

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 です。

use_include_path

include_path からファイルを探します。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例

例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;
}
?>

注意

注意: オプションのパラメータ config_options と enconding は Tidy 2.0 で追加されました。

参考


tidy
PHP Manual