<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.misc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.highlight-string.php',
    1 => 'highlight_string',
    2 => 'Applique la syntaxe coloris&eacute;e &agrave; du code PHP',
  ),
  'up' => 
  array (
    0 => 'ref.misc.php',
    1 => 'Fonctions diverses',
  ),
  'prev' => 
  array (
    0 => 'function.highlight-file.php',
    1 => 'highlight_file',
  ),
  'next' => 
  array (
    0 => 'function.hrtime.php',
    1 => 'hrtime',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/misc/functions/highlight-string.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.highlight-string" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">highlight_string</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">highlight_string</span> &mdash; <span class="dc-title">Applique la syntaxe colorisée à du code PHP</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.highlight-string-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>highlight_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"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$return</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></span></div>

  <p class="simpara">
   Affiche ou retourne le code HTML de la version colorisée du code PHP contenu
   dans le paramètre <code class="parameter">str</code>, en utilisant les couleurs du
   système interne de colorisation de PHP.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.highlight-string-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Le code PHP à coloriser. Doit également inclure les balises d&#039;ouverture.
      </p>
     </dd>
    
    
     <dt><code class="parameter">return</code></dt>
     <dd>
      <p class="para">
       Définir ce paramètre à <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> pour faire que cette fonction retourne
       le code colorisé.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.highlight-string-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Si le second paramètre optionnel <code class="parameter">return</code> est fourni,
   et vaut <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> alors <span class="function"><strong>highlight_string()</strong></span> retournera
   la chaîne colorisée au lieu de l&#039;afficher immédiatement. Si le second
   paramètre ne vaut pas <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> alors <span class="function"><strong>highlight_string()</strong></span> 
   retournera <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.highlight-string-changelog">
  <h3 class="title">Historique</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.4.0</td>
       <td>
        Le type de retour est passé de <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span> à <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></span>.
       </td>
      </tr>

      <tr>
       <td>8.3.0</td>
       <td>
        Le HTML résultant a changé.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.highlight-string-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>highlight_string()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />highlight_string</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;?php phpinfo(); ?&gt;'</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;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php phpinfo&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(); &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;</pre>
</div>
    </div>
    <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus en PHP 8.3 :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">&lt;pre&gt;&lt;code style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php phpinfo&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(); &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.highlight-string-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">
 Lorsque le paramètre <code class="parameter">return</code> est utilisé, cette fonction utilise la mise en tampon
 (buffer) interne de sortie, il ne peut donc pas être utilisé dans la fonction de rappel de <span class="function"><a href="function.ob-start.php" class="function">ob_start()</a></span>.
</p></p></blockquote>
  <p class="para">
   Le code HTML généré est sujet à changement.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.highlight-string-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.highlight-file.php" class="function" rel="rdfs-seeAlso">highlight_file()</a> - Colorisation syntaxique d'un fichier</span></li>
    <li><a href="misc.configuration.php#ini.syntax-highlighting" class="link">Les directives INI de coloration</a></li>
   </ul>
  </p>
 </div>


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