<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.ip2long.php',
    1 => 'ip2long',
    2 => 'Konvertiert eine gem&auml;&szlig; IPv4-Protokoll angegebene IP-Adresse vom
   Punkt-Format in ein Long Integer',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Netzwerk-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.inet-pton.php',
    1 => 'inet_pton',
  ),
  'next' => 
  array (
    0 => 'function.long2ip.php',
    1 => 'long2ip',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    '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">
   Konvertiert eine gemäß IPv4-Protokoll angegebene IP-Adresse vom
   Punkt-Format in ein Long Integer
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ip2long-description">
  <h3 class="title">Beschreibung</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">$ip</code></span>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Die Funktion <span class="function"><strong>ip2long()</strong></span> erzeugt aus einer im Punkt-Format
   angegebenen IPv4-Adresse ein Long Integer.
  </p>
  <p class="para">
   <span class="function"><strong>ip2long()</strong></span> funktioniert auch mit unvollständigen
   IP-Adressen. Lesen Sie <a href="http://ps-2.kev009.com/wisclibrary/aix52/usr/share/man/info/en_US/a_doc_lib/libs/commtrf2/inet_addr.htm" class="link external">&raquo;&nbsp;http://ps-2.kev009.com/wisclibrary/aix52/usr/share/man/info/en_US/a_doc_lib/libs/commtrf2/inet_addr.htm</a>, um weitere
   Informationen zu erhalten.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ip2long-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">ip</code></dt>
     <dd>
      <p class="para">
       Eine Adresse im Standardformat.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ip2long-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein Long Integer zurück. Ist <code class="parameter">ip</code> ungültig, wird
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ip2long-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>ip2long()</strong></span>-Beispiel:</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.example.com'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$out </span><span style="color: #007700">= </span><span style="color: #DD0000">"Die folgenden URLs entsprechen sich:&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.example.com/, http://' </span><span style="color: #007700">. </span><span style="color: #0000BB">$ip </span><span style="color: #007700">. </span><span style="color: #DD0000">'/, and 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>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 Eine IP-Adresse anzeigen</strong></p>
    <div class="example-contents"><p>
     Das zweite Beispiel zeigt, wie eine konvertierte Adresse mittels
     <span class="function"><a href="function.printf.php" class="function">printf()</a></span> ausgegeben werden kann:
    </p></div>
    <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.example.com'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$long </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 /><br />if (</span><span style="color: #0000BB">$long </span><span style="color: #007700">== -</span><span style="color: #0000BB">1 </span><span style="color: #007700">|| </span><span style="color: #0000BB">$long </span><span style="color: #007700">=== </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'Ungültige IP, versuchen Sie es noch einmal'</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #0000BB">$ip   </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;            </span><span style="color: #FF8000">// 192.0.34.166<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$long </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;            </span><span style="color: #FF8000">// 3221234342 (-1073732954 auf 32-bit Systemen aufgrund des Integer-Überlaufs)<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">)); </span><span style="color: #FF8000">// 3221234342<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.ip2long-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Da der <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>-Typ von PHP vorzeichenbehaftet ist und viele
    IP-Adressen auf 32-bit Architekturen in einen negativen Integerwert
    aufgelöst werden, sollten Sie dort die Formatierungsangabe &quot;%u&quot; für
    <span class="function"><a href="function.sprintf.php" class="function">sprintf()</a></span> und <span class="function"><a href="function.printf.php" class="function">printf()</a></span> verwenden, um
    eine Stringdarstellung der vorzeichenlosen IP-Adresse zu erhalten.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    <span class="function"><strong>ip2long()</strong></span> gibt <code class="literal">-1</code> für die IP-Adresse <code class="literal">255.255.255.255</code>
    auf 32-Bit-Systemen zurück, da der Integer-Wert überläuft.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ip2long-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.long2ip.php" class="function" rel="rdfs-seeAlso">long2ip()</a> - Konvertiert eine Long-Integer-Adresse in einen String, der das (IPv4)
   Internet-Standard-Punktformat enth&auml;lt (&quot;Dotted-Format&quot;)</span></li>
    <li><span class="function"><a href="function.sprintf.php" class="function" rel="rdfs-seeAlso">sprintf()</a> - Gibt einen formatierten String zur&uuml;ck</span></li>
   </ul>
  </p>
 </div>


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