sean Wed Aug 4 14:25:19 2004 EDT
Modified files: /phpdoc/en/reference/network/functions ip2long.xml Log: -Removed the . in refpurpose -Removed third (redundant) example -Modified second example to support PHP 4 and PHP 5 http://cvs.php.net/diff.php/phpdoc/en/reference/network/functions/ip2long.xml?r1=1.8&r2=1.9&ty=u Index: phpdoc/en/reference/network/functions/ip2long.xml diff -u phpdoc/en/reference/network/functions/ip2long.xml:1.8 phpdoc/en/reference/network/functions/ip2long.xml:1.9 --- phpdoc/en/reference/network/functions/ip2long.xml:1.8 Wed Aug 4 13:54:31 2004 +++ phpdoc/en/reference/network/functions/ip2long.xml Wed Aug 4 14:25:19 2004 @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <!-- splitted from ./en/functions/network.xml, last change in rev 1.18 --> <refentry id="function.ip2long"> <refnamediv> <refname>ip2long</refname> <refpurpose> Converts a string containing an (IPv4) Internet Protocol dotted address - into a proper address. + into a proper address </refpurpose> </refnamediv> <refsect1> @@ -55,39 +55,16 @@ </para> <para> This second example shows how to print a converted address with the - <function>printf</function> function in PHP 4: + <function>printf</function> function in both PHP 4 and PHP 5: <example> - <title>Displaying an IP address (PHP 4)</title> + <title>Displaying an IP address</title> <programlisting role="php"> <![CDATA[ <?php $ip = gethostbyname("www.example.com"); $long = ip2long($ip); -if ($long === -1) { - echo "Invalid IP, please try again"; -} else { - echo $ip . "\n"; // 192.0.34.166 - echo $long . "\n"; // -1073732954 - printf("%u\n", ip2long($ip)); // 3221234342 -} -?> -]]> - </programlisting> - </example> - </para> - <para> - This third example shows how to print a converted address with the - <function>printf</function> function in PHP 5: - <example> - <title>Displaying an IP address (PHP 5)</title> - <programlisting role="php"> -<![CDATA[ -<?php -$ip = gethostbyname("www.example.com"); -$long = ip2long($ip); - -if ($long === false) { +if ($long == -1 || $long === FALSE) { echo "Invalid IP, please try again"; } else { echo $ip . "\n"; // 192.0.34.166