説明
public tidy::__construct
([ string|null $filename
= null
[, array|string|null $config
= null
[, string|null $encoding
= null
[, bool $useIncludePath
= false
]]]] )
新しい tidy オブジェクトを作成します。
パラメータ
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 からファイルを探します。
変更履歴
バージョン | 説明 |
---|---|
8.0.0 | filename , config ,
|
例
例1 tidy::__construct() の例
<?php$html = <<< HTML<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22><html xmlns="http://www.w3.org/1999/xhtml%22 xml:lang="en" lang="en"><head><title>title</title></head><body><p>paragraph <bt />text</p></body></html>HTML;$tidy = new tidy();$tidy->ParseString($html);$tidy->cleanRepair();if ($tidy->errorBuffer) { echo "The following errors were detected:\n"; echo $tidy->errorBuffer;}?>
上の例の出力は以下となります。
The following errors were detected: line 8 column 14 - Error: <bt> is not recognized! line 8 column 14 - Warning: discarding unexpected <bt>