php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62440 parameter in ip2long function
Submitted: 2012-06-28 15:58 UTC Modified: 2012-07-18 19:52 UTC
From: billsion at gmail dot com Assigned: googleguy (profile)
Status: Closed Package: Network related
PHP Version: Irrelevant OS: Ubuntu 10.0.4, php version 5.3.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: billsion at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-28 15:58 UTC] billsion at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.ip2long#refsect1-function.ip2long-examples
---


Test script:
---------------
<?php
$ip = long2ip(ip2long("10.0.0")); // "0.0.0.0"
$ip = long2ip(ip2long("10.0.256")); // "0.0.0.0"
?>

consult to the documentation of these two example. the two line of codes will return valid IP address. but in fact, in PHP 5.3.2, it return 0.0.0.0.

<?php
echo ip2long('127.0.256'); //return 0.0.0.0
echo ip2long('127.0.255.0');//return 0.0.0.0
?>



Expected result:
----------------
refer to the documentation: 

<?php
$ip = long2ip(ip2long("10.0.0")); // "10.0.0.0"
$ip = long2ip(ip2long("10.0.256")); // "10.0.1.0"
?>



it will return 10.0.0.0 and 10.0.1.0 in my environment, but it's not, it returned 0.0.0.0. the documentation said that the parameter required a standard format address. parameters in example are not standard format address, and it's return value is not correct. 

This snippet of example should be correct.

Actual result:
--------------
<?php
$ip = long2ip(ip2long("10.0.0")); // "10.0.0.0"
$ip = long2ip(ip2long("10.0.256")); // "10.0.1.0"
?>

actual result is 0.0.0.0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-18 18:43 UTC] googleguy@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: googleguy@php.ne
 [2012-07-18 19:43 UTC] googleguy@php.net
Automatic comment from SVN on behalf of googleguy
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=326693
Log: Removed invalid example. which fixes Bug #62440
 [2012-07-18 19:49 UTC] googleguy@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Hi, this example has been removed as it was not valid behavior. The function is 
documented to return a boolean false on failure (see change log note for PHP 
version 5.2.10 on the documentation page).

Please allow time for the mirrors to update. Thank you for making the PHP 
documentation better!
 [2012-07-18 19:49 UTC] googleguy@php.net
-Status: Assigned +Status: Closed
 [2012-07-18 19:52 UTC] nikic@php.net
-Assigned To: googleguy@php.ne +Assigned To: googleguy
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 04:01:34 2024 UTC