1--TEST-- 2ip2long() & long2ip() tests 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE == 4) die("skip this test is for >32bit platform only"); 6?> 7--FILE-- 8<?php 9 10$array = array( 11 "127.0.0.1", 12 "10.0.0.1", 13 "255.255.255.255", 14 "255.255.255.0", 15 "0.0.0.0", 16 "66.163.161.116", 17); 18 19foreach ($array as $ip) { 20 var_dump($long = ip2long($ip)); 21 var_dump(long2ip($long)); 22} 23 24var_dump(ip2long("")); 25var_dump(ip2long("777.777.777.777")); 26var_dump(ip2long("111.111.111.111")); 27 28var_dump(long2ip(-110000)); 29var_dump(long2ip(PHP_INT_MAX)); 30var_dump(long2ip(PHP_INT_MIN)); 31 32echo "Done\n"; 33?> 34--EXPECT-- 35int(2130706433) 36string(9) "127.0.0.1" 37int(167772161) 38string(8) "10.0.0.1" 39int(4294967295) 40string(15) "255.255.255.255" 41int(4294967040) 42string(13) "255.255.255.0" 43int(0) 44string(7) "0.0.0.0" 45int(1118019956) 46string(14) "66.163.161.116" 47bool(false) 48bool(false) 49int(1869573999) 50string(13) "255.254.82.80" 51string(15) "255.255.255.255" 52string(7) "0.0.0.0" 53Done 54