<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.html-entity-decode.php',
    1 => 'html_entity_decode',
    2 => 'Converte le entit&agrave; HTML nei corrispondenti caratteri',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.hex2bin.php',
    1 => 'hex2bin',
  ),
  'next' => 
  array (
    0 => 'function.htmlentities.php',
    1 => 'htmlentities',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/strings/functions/html-entity-decode.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.html-entity-decode" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">html_entity_decode</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">html_entity_decode</span> &mdash; <span class="dc-title">
     Converte le entità HTML nei corrispondenti caratteri
    </span></p>

   </div>
   <div class="refsect1 unknown-1294" id="refsect1-function.html-entity-decode-unknown-1294">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>html_entity_decode</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.integer.php" class="type int">int</a></span> <code class="parameter">$quote_style</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$charset</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

    <p class="para rdfs-comment">
     La funzione <span class="function"><strong>html_entity_decode()</strong></span> è l&#039;opposto di
     <span class="function"><a href="function.htmlentities.php" class="function">htmlentities()</a></span> converte tutte le entità HTML presenti
     nel parametro <code class="parameter">string</code> nel corrispondente carattere.
    </p>
    <p class="para">
     Il secondo parametro,
     <code class="parameter">quote_style</code>, opzionale, indica cosa occorre fare per gli apici
     &#039;singoli&#039; e &quot;doppi&quot;. Sono possibili tre scelte indicate da tre
     costanti con default <strong><code><a href="string.constants.php#constant.ent-compat">ENT_COMPAT</a></code></strong>:
     <table class="doctable table">
      <caption><strong>Costanti disponibili per <code class="parameter">quote_style</code></strong></caption>
      
       <thead>
        <tr>
         <th>Nome della costante</th>
         <th>Descrizione</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><strong><code><a href="string.constants.php#constant.ent-compat">ENT_COMPAT</a></code></strong></td>
         <td>Converte gli apici doppi e lascia inalterati gli apici singoli.</td>
        </tr>

        <tr>
         <td><strong><code><a href="string.constants.php#constant.ent-quotes">ENT_QUOTES</a></code></strong></td>
         <td>Converte sia gli apici doppi sia gli apici singoli.</td>
        </tr>

        <tr>
         <td><strong><code><a href="string.constants.php#constant.ent-noquotes">ENT_NOQUOTES</a></code></strong></td>
         <td>Lascia entrambi i tipi di apici inalterati.</td>
        </tr>

       </tbody>
      
     </table>

    </p>
    <p class="para">
     Per il terzo parametro opzionale, <code class="parameter">charset</code>, si utilizza
     come default il set di caratteri ISO-8859-1. Questo parametro indica quale
     set di caratteri utilizzare per la conversione.
    </p>
    


<p class="para">
 Elenco dei set di caratteri supportati:
 <table class="doctable table">
  <caption><strong>Set di caratteri supportati</strong></caption>
  
   <thead>
    <tr>
     <th>Set di caratteri</th>
     <th>Alias</th>
     <th>Descrizione</th>
    </tr>

   </thead>

   <tbody class="tbody">
    <tr>
     <td>ISO-8859-1</td>
     <td>ISO8859-1</td>
     <td>
      Western European, Latin-1.
     </td>
    </tr>

    <tr>
     <td>ISO-8859-5</td>
     <td>ISO8859-5</td>
     <td>
      Il charset cirillico poco utilizzato (Latin/Cyrillic).
     </td>
    </tr>

    <tr>
     <td>ISO-8859-15</td>
     <td>ISO8859-15</td>
     <td>
      Western European, Latin-9. Con in più il simbolo dell&#039;Euro e i caratteri francesi 
      e finnici mancanti in Latin-1 (ISO-8859-1).
     </td>
    </tr>

    <tr>
     <td>UTF-8</td>
     <td class="empty">&nbsp;</td>
     <td>
      Set ASCII compatibile con il set multi-byte Unicode su 8-bit.
     </td>
    </tr>

    <tr>
     <td>cp866</td>
     <td>ibm866, 866</td>
     <td>
      Set di caratteri cirillico specifico del Dos.
     </td>
    </tr>

    <tr>
     <td>cp1251</td>
     <td>Windows-1251, win-1251, 1251</td>
     <td>
      Set di caratteri cirillico specifico di Windows.
     </td>
    </tr>

    <tr>
     <td>cp1252</td>
     <td>Windows-1252, 1252</td>
     <td>
      Set di caratteri specifico di Windows per l&#039;Europa occidentale.
     </td>
    </tr>

    <tr>
     <td>KOI8-R</td>
     <td>koi8-ru, koi8r</td>
     <td>
      Russo.
     </td>
    </tr>

    <tr>
     <td>BIG5</td>
     <td>950</td>
     <td>
      Cinese tradizionale, usato principalmente a Taiwan.
     </td>
    </tr>

    <tr>
     <td>GB2312</td>
     <td>936</td>
     <td>
      Cinese semplificato, set di caratteri nazionale standard.
     </td>
    </tr>

    <tr>
     <td>BIG5-HKSCS</td>
     <td class="empty">&nbsp;</td>
     <td>
      Big5 con estensioni per Hong Kong, cinese tradizionale.
     </td>
    </tr>

    <tr>
     <td>Shift_JIS</td>
     <td>SJIS, SJIS-win, cp932, 932</td>
     <td>
      Giapponese.
     </td>
    </tr>

    <tr>
     <td>EUC-JP</td>
     <td>EUCJP, eucJP-win</td>
     <td>
      Giapponese.
     </td>
    </tr>

    <tr>
     <td>MacRoman</td>
     <td class="empty">&nbsp;</td>
     <td>
      Charset che veniva utilizzato dal Mac OS.
     </td>
    </tr>

    <tr>
     <td><code class="literal">&#039;&#039;</code></td>
     <td class="empty">&nbsp;</td>
     <td>
      Una stringa vuota attiva il rilevamento della codifica dallo script (Zend multibyte),
      <a href="ini.core.php#ini.default-charset" class="link">default_charset</a> e l&#039;attuale
      locale (guarda <span class="function"><a href="function.nl-langinfo.php" class="function">nl_langinfo()</a></span> e
      <span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span>), in quest&#039;ordine. Non consigliato.
     </td>
    </tr>

   </tbody>
  
 </table>

 <blockquote class="note"><p><strong class="note">Nota</strong>: 
  <span class="simpara">
   Ogni altro set di caratteri non è riconosciuto. Sarà invece utilizzata la codifica
   predefinita e verrà mostrato un avviso.
  </span>
 </p></blockquote>
</p>

    
    <p class="para">
     <div class="example" id="example-1">
      <p><strong>Example #1 Decodifica delle entità HTML</strong></p>
      <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$orig </span><span style="color: #007700">= </span><span style="color: #DD0000">"I'll \"walk\" the &lt;b&gt;dog&lt;/b&gt; now"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$a </span><span style="color: #007700">= </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$orig</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">html_entity_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$a</span><span style="color: #007700">; </span><span style="color: #FF8000">// I'll &amp;quot;walk&amp;quot; the &amp;lt;b&amp;gt;dog&amp;lt;/b&amp;gt; now<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$b</span><span style="color: #007700">; </span><span style="color: #FF8000">// I'll "walk" the &lt;b&gt;dog&lt;/b&gt; now<br /><br /><br />// Per utilizzatori di versioni di PHP antecedenti alla 4.3.0:<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">unhtmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">) <br />{<br />    </span><span style="color: #0000BB">$trans_tbl </span><span style="color: #007700">= </span><span style="color: #0000BB">get_html_translation_table</span><span style="color: #007700">(</span><span style="color: #0000BB">HTML_ENTITIES</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$trans_tbl </span><span style="color: #007700">= </span><span style="color: #0000BB">array_flip</span><span style="color: #007700">(</span><span style="color: #0000BB">$trans_tbl</span><span style="color: #007700">);<br />    return </span><span style="color: #0000BB">strtr</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #0000BB">$trans_tbl</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">unhtmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$c</span><span style="color: #007700">; </span><span style="color: #FF8000">// I'll "walk" the &lt;b&gt;dog&lt;/b&gt; now<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

     </div>
    </p>
    <p class="para">
     <blockquote class="note"><p><strong class="note">Nota</strong>: 
      <p class="para">
       Ci si può chiedere come mai la sequenza trim(html_entity_decode(&#039;&amp;nbsp;&#039;)); non
       produca una stringa vuota; questo accade perché l&#039;intità &#039;&amp;nbsp;&#039;
       non corrisponde al codice ASCII 32 (che verrebbe rimosso
       da <span class="function"><a href="function.trim.php" class="function">trim()</a></span>), ma, nella codifica di default ISO-8859-1, corrisponde
       al carattere ASCII 160 (0xa0).
      </p>
     </p></blockquote>
    </p>
    <p class="para">
     Vedere anche <span class="function"><a href="function.htmlentities.php" class="function">htmlentities()</a></span>,
     <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>,
     <span class="function"><a href="function.get-html-translation-table.php" class="function">get_html_translation_table()</a></span>, 
     and <span class="function"><a href="function.urldecode.php" class="function">urldecode()</a></span>.
    </p>
   </div>

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