mirror of
https://github.com/php/doc-de.git
synced 2026-03-24 15:22:14 +01:00
149 lines
4.1 KiB
XML
149 lines
4.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 184f3f7bd45643cb80f828d0bb001991ec3a5fad Maintainer: sammywg Status: ready -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="function.ip2long">
|
|
<refnamediv>
|
|
<refname>ip2long</refname>
|
|
<refpurpose>
|
|
Konvertiert eine gemäß IPv4-Protokoll angegebene IP-Adresse vom
|
|
Punkt-Format in ein Long Integer
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>int</type><type>false</type></type><methodname>ip2long</methodname>
|
|
<methodparam><type>string</type><parameter>ip</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Die Funktion <function>ip2long</function> erzeugt aus einer im Punkt-Format
|
|
angegebenen IPv4-Adresse ein Long Integer.
|
|
</para>
|
|
<para>
|
|
<function>ip2long</function> funktioniert auch mit unvollständigen
|
|
IP-Adressen. Lesen Sie <link
|
|
xlink:href="&url.ip2long.tech;">&url.ip2long.tech;</link>, um weitere
|
|
Informationen zu erhalten.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>ip</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Eine Adresse im Standardformat.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Gibt ein Long Integer zurück. Ist <parameter>ip</parameter> ungültig, wird
|
|
&false; zurückgegeben.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>ip2long</function>-Beispiel:</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ip = gethostbyname('www.example.com');
|
|
$out = "Die folgenden URLs entsprechen sich:<br />\n";
|
|
$out .= 'http://www.example.com/, http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/<br />\n";
|
|
echo $out;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Eine IP-Adresse anzeigen</title>
|
|
<para>
|
|
Das zweite Beispiel zeigt, wie eine konvertierte Adresse mittels
|
|
<function>printf</function> ausgegeben werden kann:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ip = gethostbyname('www.example.com');
|
|
$long = ip2long($ip);
|
|
|
|
if ($long == -1 || $long === FALSE) {
|
|
echo 'Ungültige IP, versuchen Sie es noch einmal';
|
|
} else {
|
|
echo $ip . "\n"; // 192.0.34.166
|
|
echo $long . "\n"; // 3221234342 (-1073732954 auf 32-bit Systemen aufgrund des Integer-Überlaufs)
|
|
printf("%u\n", ip2long($ip)); // 3221234342
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Da der <type>int</type>-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 "%u" für
|
|
<function>sprintf</function> und <function>printf</function> verwenden, um
|
|
eine Stringdarstellung der vorzeichenlosen IP-Adresse zu erhalten.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
<function>ip2long</function> gibt <literal>-1</literal> für die IP-Adresse <literal>255.255.255.255</literal>
|
|
auf 32-Bit-Systemen zurück, da der Integer-Wert überläuft.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>long2ip</function></member>
|
|
<member><function>sprintf</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|