<?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.htmlentities.php',
    1 => 'htmlentities',
    2 => 'Converte tutti i possibili caratteri in entit&agrave; HTML',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.html-entity-decode.php',
    1 => 'html_entity_decode',
  ),
  'next' => 
  array (
    0 => 'function.htmlspecialchars.php',
    1 => 'htmlspecialchars',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/strings/functions/htmlentities.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.htmlentities" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">htmlentities</h1>
    <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">htmlentities</span> &mdash; <span class="dc-title">
     Converte tutti i possibili caratteri in entità HTML
    </span></p>

   </div>
   <div class="refsect1 unknown-1297" id="refsect1-function.htmlentities-unknown-1297">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>htmlentities</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">
     Questa funzione è identica a 
     <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span> tranne che
     <span class="function"><strong>htmlentities()</strong></span> converte tutti i caratteri
     che hanno una corrispettiva entità HTML.
    </p>
    <p class="para">
     Come per la funzione <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>, il secondo parametro opzionale
     <code class="parameter">quote_style</code> 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">
     Il suupporto per il parametro <code class="parameter">quote</code> è stato introdotto 
     in PHP 4.0.3.
    </p>
    <p class="para">
     Come per la funzione <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>, questa ha un terzo parametro
     <code class="parameter">charset</code>, opzionale, che definisce quale set di caratteri
     utilizzare per la conversione. Il supporto per questo parametro è stato aggiunto in PHP 4.1.0.
     Attualmente per default si utilizza il set ISO-8859-1.
    </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">
     Se si deve esere una decodifica (un giro al contrario) occorre utilizzare la funzione
     <span class="function"><a href="function.html-entity-decode.php" class="function">html_entity_decode()</a></span>.
    </p>
    <p class="para">
     <div class="example" id="example-1">
      <p><strong>Example #1 Un esempio di <span class="function"><strong>htmlentities()</strong></span></strong></p>
      <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">"A 'quote' is &lt;b&gt;bold&lt;/b&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Visualizza: A 'quote' is &amp;lt;b&amp;gt;bold&amp;lt;/b&amp;gt;<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Visualizza: A &amp;#039;quote&amp;#039; is &amp;lt;b&amp;gt;bold&amp;lt;/b&amp;gt;<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">ENT_QUOTES</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

     </div>
    </p>
    <p class="para">
     Vedere anche <span class="function"><a href="function.html-entity-decode.php" class="function">html_entity_decode()</a></span>, 
     <span class="function"><a href="function.get-html-translation-table.php" class="function">get_html_translation_table()</a></span>,
     <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>, <span class="function"><a href="function.nl2br.php" class="function">nl2br()</a></span>
     e <span class="function"><a href="function.urlencode.php" class="function">urlencode()</a></span>.
    </p>
   </div>

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