php[tek] 2018 : Call for Speakers


Please answer this simple SPAM challenge: max(seven, six)?
(Example: nine)

The Note You're Voting On

rasmus at mindplay dot dk
4 years ago
As pointed out by others, this function's return value is not consistent on 32 and 64-bit platforms.

Your best bet for consistent behavior across 32/64-bit platforms (and Windows) is the lowest common denominator: force the return value of ip2long() into a signed 32-bit integer, e.g.:

    var_dump(unpack('l', pack('l', ip2long(''))));

This looks idiotic, but it gives you a consistent signed integer value on all platforms.

(the arguments to both pack() and unpack() are the lower-case letter "L", not the number "1", in case it looks that way on your screen...)

<< Back to user notes page

To Top