cvs: phpdoc /en/reference/network/functions ip2long.xml

From: Date: Tue, 29 Apr 2003 22:57:38 +0000
Subject: cvs: phpdoc /en/reference/network/functions ip2long.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969352961@lists.php.net to get a copy of this message
philip Tue Apr 29 18:57:38 2003 EDT Modified files: /phpdoc/en/reference/network/functions ip2long.xml Log: Mention ip2long returns -1 on failure. Also expand the second example to demonstrate what all this stuff looks like, mention that 255.255.255.255 also returns -1, and see also sprintf(). Index: phpdoc/en/reference/network/functions/ip2long.xml diff -u phpdoc/en/reference/network/functions/ip2long.xml:1.2 phpdoc/en/reference/network/functions/ip2long.xml:1.3 --- phpdoc/en/reference/network/functions/ip2long.xml:1.2 Wed Apr 17 02:42:04 2002 +++ phpdoc/en/reference/network/functions/ip2long.xml Tue Apr 29 18:57:38 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/network.xml, last change in rev 1.18 --> <refentry id="function.ip2long"> <refnamediv> @@ -18,7 +18,9 @@ <para> The function <function>ip2long</function> generates an IPv4 Internet network address from its Internet standard format (dotted string) - representation. + representation. If <parameter>ip_address</parameter> is invalid than + <literal>-1</literal> is returned. Note that <literal>-1</literal> + does not evaluate as &false; in PHP. <example> <title><function>ip2long</function> Example</title> <programlisting role="php"> @@ -47,16 +49,30 @@ <programlisting role="php"> <![CDATA[ <?php -$ip = gethostbyname("www.example.com"); -printf("%u\n", ip2long($ip)); -echo $out; +$ip = gethostbyname("www.example.com"); +$long = ip2long($ip); + +if ($long === -1) { + print "Invalid IP, please try again"; +} else { + print $ip . "\n"; // 192.0.34.166 + print $long . "\n"; // -1073732954 + printf("%u\n", ip2long($ip)); // 3221234342 +} ?> ]]> </programlisting> </example> </para> + <note> + <para> + <function>ip2long</function> will return <literal>-1</literal> for + the ip 255.255.255.255 + </para> + </note> <para> - See also: <function>long2ip</function> + See also <function>long2ip</function> and + <function>sprintf</function>. </para> </refsect1> </refentry>

« previous php.doc (#969352961) next »