<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.ip2long.php',
    1 => 'ip2long',
    2 => 'Converts a string containing an (IPv4) Internet Protocol dotted address
      into a proper address.
      Converte una stringa contenente un indirizzo di rete del Protocollo Internet (IPv4)
      in un indirizzo espresso come tipo di dato int.',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Network Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.inet-pton.php',
    1 => 'inet_pton',
  ),
  'next' => 
  array (
    0 => 'function.long2ip.php',
    1 => 'long2ip',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/network/functions/ip2long.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ip2long" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">ip2long</h1>
    <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ip2long</span> &mdash; <span class="dc-title">
      Converts a string containing an (IPv4) Internet Protocol dotted address
      into a proper address.
      Converte una stringa contenente un indirizzo di rete del Protocollo Internet (IPv4)
      in un indirizzo espresso come tipo di dato int.
    </span></p>
 
   </div>
   <div class="refsect1 unknown-1102" id="refsect1-function.ip2long-unknown-1102">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>ip2long</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$indirizzo_ip</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

    <p class="para rdfs-comment">
     La funzione <span class="function"><strong>ip2long()</strong></span> genera un indirizzo di rete Internet IPv4
     a partire dalla rappresentazione in formato standard 
     (stringa separata da punti).
     <div class="example" id="example-1">
      <p><strong>Example #1 Esempio di <span class="function"><strong>ip2long()</strong></span></strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$ip </span><span style="color: #007700">= </span><span style="color: #0000BB">gethostbyname</span><span style="color: #007700">(</span><span style="color: #DD0000">"www.php.net"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$out </span><span style="color: #007700">= </span><span style="color: #DD0000">"I seguenti URL sono equivalenti:&lt;br&gt;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$out </span><span style="color: #007700">.= </span><span style="color: #DD0000">"http://www.php.net/, http://"</span><span style="color: #007700">.</span><span style="color: #0000BB">$ip</span><span style="color: #007700">.</span><span style="color: #DD0000">"/, e http://"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%u"</span><span style="color: #007700">,</span><span style="color: #0000BB">ip2long</span><span style="color: #007700">(</span><span style="color: #0000BB">$ip</span><span style="color: #007700">)).</span><span style="color: #DD0000">"/&lt;br&gt;\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$out</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

     </div>
     <blockquote class="note"><p><strong class="note">Nota</strong>: 
      <p class="para">
       Poiché il tipo di dato integer in PHP è signed e molti indirizzi IP risulterebbero essere 
       interi negativi, è necessario usare il formattatore &quot;%u&quot; della funzione
       <span class="function"><a href="function.sprintf.php" class="function">sprintf()</a></span> e <span class="function"><a href="function.printf.php" class="function">printf()</a></span> per ottenere
       la rappresentazione in stringa dell&#039;indirizzo IP in modo nsigned.
      </p>
     </p></blockquote>
     Questo secondo esempio mostra come stampare un indirizzo convertito, usando la
     funzione <span class="function"><a href="function.printf.php" class="function">printf()</a></span>:
     <div class="example" id="example-2">
      <p><strong>Example #2 Visualizzazione di un indirizzo IP</strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$ip </span><span style="color: #007700">= </span><span style="color: #0000BB">gethostbyname</span><span style="color: #007700">(</span><span style="color: #DD0000">"www.php.net"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%u\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">ip2long</span><span style="color: #007700">(</span><span style="color: #0000BB">$ip</span><span style="color: #007700">));<br />echo </span><span style="color: #0000BB">$out</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.long2ip.php" class="function">long2ip()</a></span>
    </p>
   </div>

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