Funções do Tidy
PHP Manual

tidy::__construct

(PHP 5, PECL tidy >= 0.5.2)

tidy::__constructCria um novo objeto tidy

Descrição

tidy tidy::__construct ([ string $filename [, mixed $config [, string $encoding [, bool $use_include_path ]]]] )

tidy::__construct() cria um novo objeto tidy.

Se o parâmetro filename é dado, esta função irá ler o arquivo e também inicializar o objeto com o arquivo, como tidy_parse_file().

O parâmetro config pode ser passado tanto como um array ou como string. Se você passar como uma string, isto significa o nome do arquivo de configuração. De outra forma será interpretador como as sendo as próprias opções. Veja » http://tidy.sourceforge.net/docs/quickref.html para uma explicação sobre cada opção.

O parâmetro encoding configura o encoding dos documentos de input e output. Os valores possíveis para encoding são: ascii, latin0, latin1, raw, utf8, iso2022, mac, win1252, ibm858, utf16, utf16le, utf16be, big5 and shiftjis.

Exemplo #1 Exemplo da 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">

<html xmlns="http://www.w3.org/1999/xhtml" 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;
}

?>

O exemplo acima irá imprimir:

The following errors were detected:
line 8 column 14 - Error: <bt> is not recognized!
line 8 column 14 - Warning: discarding unexpected <bt>

Veja também tidy_parse_file() e tidy_parse_string().


Funções do Tidy
PHP Manual