3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "Leading zeroes are not significant: "; var_dump(inet_pton("2001:0010::") == inet_pton("2001:10::")); echo "2001:0010:: "; var_dump(filter_var("2001:0010::", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); echo "2001:10:: "; var_dump(filter_var("2001:10::", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); echo "\n"; echo "Testing manually: "; $inet = array_map("hexdec", array_map("bin2hex", str_split(inet_pton("2001:10::"), 2))); var_dump($inet[0] != 0x2001 || ($inet[1] & 0xFFF0) != 0x0010);
Output for 7.4.25, 8.0.12, 8.1rc3
Leading zeroes are not significant: bool(true) 2001:0010:: bool(false) 2001:10:: bool(false) Testing manually: bool(false)
Output for 5.6.38, 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.24, 8.0.0 - 8.0.11, 8.1rc1 - rc2
Leading zeroes are not significant: bool(true) 2001:0010:: bool(false) 2001:10:: string(9) "2001:10::" Testing manually: bool(false)

preferences:
61.39 ms | 462 KiB | 5 Q