【发布时间】:2019-12-06 17:28:46
【问题描述】:
我有这个适用于 IPv4 地址的功能:
# We need to be able to check if an ip_address in a particular range
protected function ipInRange($lower_range_ip_address, $upper_range_ip_address, $needle_ip_address)
{
# Get the numeric reprisentation of the IP Address with IP2long
$min = ip2long($lower_range_ip_address);
$max = ip2long($upper_range_ip_address);
$needle = ip2long($needle_ip_address);
# Then it's as simple as checking whether the needle falls between the lower and upper ranges
return (($needle >= $min) AND ($needle <= $max));
}
如何将 IPv6 地址转换为工作? 谢谢
【问题讨论】:
标签: php laravel-5 ip ip-address