dave Fri Aug 6 06:04:01 2004 EDT
Modified files:
/phpdoc/en/reference/network/functions ip2long.xml
Log:
- Fix #25997.
http://cvs.php.net/diff.php/phpdoc/en/reference/network/functions/ip2long.xml?r1=1.10&r2=1.11&ty=u
Index: phpdoc/en/reference/network/functions/ip2long.xml
diff -u phpdoc/en/reference/network/functions/ip2long.xml:1.10
phpdoc/en/reference/network/functions/ip2long.xml:1.11
--- phpdoc/en/reference/network/functions/ip2long.xml:1.10 Wed Aug 4 14:33:09
2004
+++ phpdoc/en/reference/network/functions/ip2long.xml Fri Aug 6 06:04:01 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
<!-- splitted from ./en/functions/network.xml, last change in rev 1.18 -->
<refentry id="function.ip2long">
<refnamediv>
@@ -28,10 +28,9 @@
<parameter>ip_address</parameter> is invalid.
</para>
</note>
- <para>
- <example>
- <title><function>ip2long</function> Example</title>
- <programlisting role="php">
+ <example>
+ <title><function>ip2long</function> Example</title>
+ <programlisting role="php">
<![CDATA[
<?php
$ip = gethostbyname('www.example.com');
@@ -40,9 +39,8 @@
echo $out;
?>
]]>
- </programlisting>
- </example>
- </para>
+ </programlisting>
+ </example>
<para>
<note>
<para>
@@ -56,9 +54,10 @@
<para>
This second example shows how to print a converted address with the
<function>printf</function> function in both PHP 4 and PHP 5:
- <example>
- <title>Displaying an IP address</title>
- <programlisting role="php">
+ </para>
+ <example>
+ <title>Displaying an IP address</title>
+ <programlisting role="php">
<![CDATA[
<?php
$ip = gethostbyname('www.example.com');
@@ -73,18 +72,35 @@
}
?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ <para>
+ <function>ip2long</function> should not be used as the sole form
+ of IP validation. Combine it with <function>long2ip</function>:
</para>
+ <example>
+ <title>IP validation</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// make sure IPs are valid. also converts a non-complete IP into
+// a proper dotted quad as explained below.
+$ip = long2ip(ip2long("127.0.0.1")); // "127.0.0.1"
+$ip = long2ip(ip2long("10.0.0")); // "10.0.0.0"
+$ip = long2ip(ip2long("10.0.256")); // "10.0.1.0"
+?>
+]]>
+ </programlisting>
+ </example>
<para>
- <function>ip2long</function> will also work with non-complete ip
+ <function>ip2long</function> will also work with non-complete IP
adresses. Read <ulink url="&url.ip2long.tech;">&url.ip2long.tech;</ulink>
for more info.
</para>
<note>
<para>
<function>ip2long</function> will return <literal>-1</literal> for
- the IP 255.255.255.255
+ the IP <literal>255.255.255.255</literal>
</para>
</note>
<para>