Bug #55738 [Bgs]: intval IP address
| From: | vlado107 at yahoo dot com | Date: | Tue, 20 Sep 2011 21:49:18 +0000 |
| Subject: | Bug #55738 [Bgs]: intval IP address | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163730@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55738&edit=1
ID: 55738
User updated by: vlado107 at yahoo dot com
Reported by: vlado107 at yahoo dot com
Summary: intval IP address
Status: Bogus
Type: Bug
Package: Unknown/Other Function
Operating System: Win
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
(number) 127.1.1.1 = 127.1
Yes, this is ok.
$ip = '127.1.1.1';
echo $ip == intval($ip);
Ti is false and it should be false because 127.1.1.1 is not equal with 127.1
Problem is if IP is 127.0.1.1
$ip = '127.0.1.1';
echo $ip == intval($ip); // true
This is 127.0.1.1 == 127.0 and it is true. How it can be true? It should be
false like in first case.
Previous Comments:
------------------------------------------------------------------------
[2011-09-20 11:27:00] laruence@php.net
sorry, typo.
(number) 127.1.1.1 = 127.1
------------------------------------------------------------------------
[2011-09-20 11:25:59] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
(number) 127.1.1.1 = 127.0
------------------------------------------------------------------------
[2011-09-20 10:02:53] vlado107 at yahoo dot com
Description:
------------
Problem in some cases when use intval($ip);
Test script:
---------------
$ip = '127.0.1.1';
echo $ip == intval($ip); // true
$ip = '127.1.1.1';
echo $ip == intval($ip); // false
Expected result:
----------------
Both result should be false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55738&edit=1