Tidy tidy::__construct

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

tidy::__construct — Constructs a new tidy object


설명

객체 지향 스타일

public tidy::__construct(
    ?string $filename = null,
    array|string|null $config = null,
    ?string $encoding = null,
    bool $useIncludePath = false
)
                

Constructs a new tidy object.


매개변수

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, big5shiftjis입니다.
useIncludePath
include_path에서 파일을 검색하십시오.

변경 로그

버전 설명
8.0.0 filename, config, encodinguseIncludePath는 이제 null을 허용합니다.

Examples

예제 #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">

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

?>
                  
                

위의 예는 다음을 출력합니다.

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

기타