PHP 8.3.4 Released!

tidy::diagnose

tidy_diagnose

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

tidy::diagnose -- tidy_diagnoseパース、修正されたマークアップの診断を行う

説明

オブジェクト指向型

public tidy::diagnose(): bool

手続き型

tidy_diagnose(tidy $tidy): bool

与えられた Tidy オブジェクト tidy に対して診断テストを実行し、 エラーバッファにドキュメントについての情報を追加します。

パラメータ

tidy

Tidy オブジェクト。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例1 tidy::diagnose() の例

<?php

$html
= <<< HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<p>paragraph</p>
HTML;

$tidy = tidy_parse_string($html);
$tidy->cleanRepair();

// 2 つの出力の違いに注意
echo $tidy->errorBuffer . "\n";

$tidy->diagnose();
echo
$tidy->errorBuffer;

?>

上の例の出力は以下となります。

line 4 column 1 - Warning: <p> isn't allowed in <head> elements
line 4 column 1 - Warning: inserting missing 'title' element
line 4 column 1 - Warning: <p> isn't allowed in <head> elements
line 4 column 1 - Warning: inserting missing 'title' element
Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
Info: Document content looks like XHTML 1.0 Strict
2 warnings, 0 errors were found!

参考

  • tidy::errorBuffer()
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top