<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Constructs a new tidy object</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="tidy.cleanrepair.html">tidy::cleanRepair</a></div> <div class="next" style="text-align: right; float: right;"><a href="tidy.diagnose.html">tidy::diagnose</a></div> <div class="up"><a href="class.tidy.html">tidy</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="tidy.construct" class="refentry"> <div class="refnamediv"> <h1 class="refname">tidy::__construct</h1> <p class="verinfo">(PHP 5, PECL tidy >= 0.5.2)</p><p class="refpurpose"><span class="refname">tidy::__construct</span> — <span class="dc-title">Constructs a new <a href="class.tidy.html" class="classname">tidy</a> object</span></p> </div> <div class="refsect1 description" id="refsect1-tidy.construct-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="methodname"><strong>tidy::__construct</strong></span> ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$config</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$use_include_path</code></span> ]]]] )</div> <p class="para rdfs-comment"> Constructs a new <a href="class.tidy.html" class="classname">tidy</a> object. </p> </div> <div class="refsect1 parameters" id="refsect1-tidy.construct-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">filename</code></em></span> <dd> <p class="para"> If the <em><code class="parameter">filename</code></em> parameter is given, this function will also read that file and initialize the object with the file, acting like <span class="function"><a href="tidy.parsefile.html" class="function">tidy_parse_file()</a></span>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">config</code></em></span> <dd> <p class="para"> The config <em><code class="parameter">config</code></em> can be passed either as an array or as a string. If a string is passed, it is interpreted as the name of the configuration file, otherwise, it is interpreted as the options themselves. </p> <p class="para"> For an explanation about each option, visit <a href="http://tidy.sourceforge.net/docs/quickref.html" class="link external">» http://tidy.sourceforge.net/docs/quickref.html</a>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">encoding</code></em></span> <dd> <p class="para"> The <em><code class="parameter">encoding</code></em> parameter sets the encoding for input/output documents. The possible values for encoding are: <em>ascii</em>, <em>latin0</em>, <em>latin1</em>, <em>raw</em>, <em>utf8</em>, <em>iso2022</em>, <em>mac</em>, <em>win1252</em>, <em>ibm858</em>, <em>utf16</em>, <em>utf16le</em>, <em>utf16be</em>, <em>big5</em>, and <em>shiftjis</em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">use_include_path</code></em></span> <dd> <p class="para"> Search for the file in the <a href="ini.core.html#ini.include-path" class="link">include_path</a>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-tidy.construct-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the new <a href="class.tidy.html" class="classname">tidy</a> instance. </p> </div> <div class="refsect1 examples" id="refsect1-tidy.construct-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4046"> <p><strong>Example #1 <span class="function"><strong>tidy::__construct()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$html </span><span style="color: #007700">= <<< HTML<br /></span><span style="color: #DD0000"><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br /><br /><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br /><head><title>title</title></head><br /><body><br /><p>paragraph <bt /><br />text</p><br /></body></html><br /><br /></span><span style="color: #007700">HTML;<br /><br /></span><span style="color: #0000BB">$tidy </span><span style="color: #007700">= new </span><span style="color: #0000BB">tidy</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-></span><span style="color: #0000BB">ParseString</span><span style="color: #007700">(</span><span style="color: #0000BB">$html</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-></span><span style="color: #0000BB">cleanRepair</span><span style="color: #007700">();<br /><br />if (</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-></span><span style="color: #0000BB">errorBuffer</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"The following errors were detected:\n"</span><span style="color: #007700">;<br /> echo </span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-></span><span style="color: #0000BB">errorBuffer</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> The following errors were detected: line 8 column 14 - Error: <bt> is not recognized! line 8 column 14 - Warning: discarding unexpected <bt> </pre></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-tidy.construct-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"> <span class="function"><a href="tidy.parsefile.html" class="function" rel="rdfs-seeAlso">tidy::parseFile()</a> - Parse markup in file or URI</span></li> <li class="member"> <span class="function"><a href="tidy.parsestring.html" class="function" rel="rdfs-seeAlso">tidy::parseString()</a> - Parse a document stored in a string</span></li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="tidy.cleanrepair.html">tidy::cleanRepair</a></div> <div class="next" style="text-align: right; float: right;"><a href="tidy.diagnose.html">tidy::diagnose</a></div> <div class="up"><a href="class.tidy.html">tidy</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>