|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-16 13:14 UTC] andrew at is dot co dot za
Description:
------------
ip2long has been changed to return "false" instead of -1 in the event of a failure, presumably to fix the historical problem of not being able to pass it "255.255.255.255", which is a valid broadcast address that evaluates to -1 when converted.
However, ip2long now returns "false" instead of -1 for "255.255.255.255", which contradicts the PHP documentation.
Reproduce code:
---------------
if (ip2long("255.255.255.255") === false) {
echo "Bad";
} else {
echo "OK";
}
Expected result:
----------------
Displays "Bad"
Actual result:
--------------
Should display "OK"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 30 14:00:01 2025 UTC |
I agree with that, but: The inet_addr() function converts the Internet host address cp from numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned. This is an obsolete interface to inet_aton, described immediately above; it is obsolete because -1 is a valid address (255.255.255.255), and inet_aton provides a cleaner way to indicate error return. If I find some time I will implement it to use inet_aton if it is supported on the platform. This will "break" BC again though...