<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.tidy.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'tidy.parsestring.php',
    1 => 'tidy::parseString',
    2 => 'Analyse un document HTML contenu dans une cha&icirc;ne',
  ),
  'up' => 
  array (
    0 => 'class.tidy.php',
    1 => 'tidy',
  ),
  'prev' => 
  array (
    0 => 'tidy.parsefile.php',
    1 => 'tidy::parseFile',
  ),
  'next' => 
  array (
    0 => 'tidy.repairfile.php',
    1 => 'tidy::repairFile',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/tidy/tidy/parsestring.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="tidy.parsestring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">tidy::parseString</h1>
  <h1 class="refname">tidy_parse_string</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8, PECL tidy &gt;= 0.5.2)</p><p class="refpurpose"><span class="refname">tidy::parseString</span> -- <span class="refname">tidy_parse_string</span> &mdash; <span class="dc-title">
   Analyse un document HTML contenu dans une chaîne
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-tidy.parsestring-description">
  <h3 class="title">Description</h3>
  <p class="para">Style orienté objet</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>tidy::parseString</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$config</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">Style procédural</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>tidy_parse_string</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$config</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="class.tidy.php" class="type tidy">tidy</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Analyse un document contenu dans une chaîne.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-tidy.parsestring-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Les données à analyser.
      </p>
     </dd>
    
    
     <dt><code class="parameter">config</code></dt>
     <dd>
      <p class="para">
       La configuration <code class="parameter">config</code> peut être passée
       sous forme de <a href="language.types.array.php" class="link">tableau</a> ou de <a href="language.types.string.php" class="link">chaîne de caractères</a>. Si une <a href="language.types.string.php" class="link">chaîne de caractères</a> est passée,
       elle est interprétée comme le nom du fichier de configuration,
       et sinon, elle est interprétée comme les options elles-mêmes.
      </p>
      <p class="para">
       Pour une explication sur chaque option, voir
       <a href="http://api.html-tidy.org/#quick-reference" class="link external">&raquo;&nbsp;http://api.html-tidy.org/#quick-reference</a>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">encoding</code></dt>
     <dd>
      <p class="para">
       Le paramètre <code class="parameter">encoding</code> configure l&#039;encodage
       pour les documents d&#039;entrée et de sortie. Les valeurs possibles sont
       <code class="literal">ascii</code>, <code class="literal">latin0</code>, <code class="literal">latin1</code>,
       <code class="literal">raw</code>, <code class="literal">utf8</code>, <code class="literal">iso2022</code>,
       <code class="literal">mac</code>, <code class="literal">win1252</code>, <code class="literal">ibm858</code>,
       <code class="literal">utf16</code>, <code class="literal">utf16le</code>, <code class="literal">utf16be</code>,
       <code class="literal">big5</code> et <code class="literal">shiftjis</code>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-tidy.parsestring-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   <span class="methodname"><strong>tidy::parseString()</strong></span> retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en cas de succès.
   <span class="function"><strong>tidy_parse_string()</strong></span> retourne une nouvelle instance de
   <span class="classname"><a href="class.tidy.php" class="classname">tidy</a></span> en cas de succès.
   Toutes deux, la méthode et la fonction retournent <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> en cas d&#039;échec.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-tidy.parsestring-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">config</code> et <code class="parameter">encoding</code> sont désormais nullables.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-tidy.parsestring-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>tidy::parseString()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />ob_start</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;<br /></span><br />&lt;html&gt;<br /> &lt;head&gt;<br />  &lt;title&gt;test&lt;/title&gt;<br /> &lt;/head&gt;<br /> &lt;body&gt;<br />  &lt;p&gt;erreur&lt;br /&gt;une autre ligne&lt;/p&gt;<br /> &lt;/body&gt;<br />&lt;/html&gt;<br /><br /><span style="color: #0000BB">&lt;?php<br />$buffer </span><span style="color: #007700">= </span><span style="color: #0000BB">ob_get_clean</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$config </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'indent' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">,<br />   </span><span style="color: #DD0000">'output-xhtml' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">,<br />   </span><span style="color: #DD0000">'wrap'</span><span style="color: #007700">, </span><span style="color: #0000BB">200</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$tidy </span><span style="color: #007700">= </span><span style="color: #0000BB">tidy_parse_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$buffer</span><span style="color: #007700">, </span><span style="color: #0000BB">$config</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF8'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cleanRepair</span><span style="color: #007700">();<br /><br />echo </span><span style="color: #0000BB">$tidy</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
           &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
 &lt;head&gt;
  &lt;title&gt;
   test
  &lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;p&gt;
   erreur&lt;br /&gt;
   une autre ligne
  &lt;/p&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-tidy.parsestring-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="tidy.parsefile.php" class="function" rel="rdfs-seeAlso">tidy::parseFile()</a> - Analyse les balises d'un fichier ou d'une URI</span></li>
   <li><span class="function"><a href="tidy.repairfile.php" class="function" rel="rdfs-seeAlso">tidy::repairFile()</a> - R&eacute;pare un fichier et le renvoie en tant que cha&icirc;ne</span></li>
   <li><span class="function"><a href="tidy.repairstring.php" class="function" rel="rdfs-seeAlso">tidy::repairString()</a> - R&eacute;pare une cha&icirc;ne HTML en utilisant un fichier de configuration optionnel</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>