#26667 [Opn]: ip2long("") = 0 intstead of -1

From: Date: Fri, 19 Dec 2003 11:41:48 +0000
Subject: #26667 [Opn]: ip2long("") = 0 intstead of -1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-52298@lists.php.net to get a copy of this message
 ID:               26667
 Updated by:       derick@php.net
 Reported By:      ovdspek at liacs dot nl
 Status:           Open
 Bug Type:         Unknown/Other Function
 Operating System: Windows NT 4 SP 6
 PHP Version:      4.3.4
 New Comment:

hmm, works for me:

derick@kossu:~$ php-4.3dev -r 'echo ip2long(""); '
-1


Previous Comments:
------------------------------------------------------------------------

[2003-12-19 06:22:34] ovdspek at liacs dot nl

Description:
------------
ip2long returns 0 if the input is an empty string. However, an empty
string is not valid, so it should return -1.

"The function ip2long() generates an IPv4 Internet network address from
its Internet standard format (dotted string) representation. If
ip_address is invalid than -1 is returned. Note that -1 does not
evaluate as FALSE in PHP."

Reproduce code:
---------------
<?php echo ip2long(""); ?>

Expected result:
----------------
-1

Actual result:
--------------
0


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=26667&edit=1


Thread (6 messages)

« previous php.bugs (#52298) next »