|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-08-21 03:09 UTC] php at linuxhosted dot ca
Description: ------------ On windows, the ip2long function does not return false on an invalid input, on other operating systems it properly returns false. Test script: --------------- var_dump(ip2long(26)); Expected result: ---------------- bool(false) Actual result: -------------- int(26) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 21:00:01 2025 UTC |
As we've been saying, the fact that this function uses a Windows specific api is the bug. It should be using inet_ntop/pton like every other OS does. Also, you say that "26" is a valid IP, which is totally wrong, the function considers 26 to be "0.0.0.26", when if it was taking it as a valid ip, it would mean that its "26.0.0.0, take for example, long2ip(ip2long("10.200")); this becomes 10.0.0.200, instead of what it should be, 10.200.0.0. Also, it makes no sense for a function that is not OS specific to have different results on different platforms, PHP is supposed to be multi-platform, so except for functions that are meant to be platform specific , functions shouldn't be giving a totally different result on different platforms, it just makes no sense.