本文整理汇总了PHP中Net_IPv6::Uncompress方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IPv6::Uncompress方法的具体用法?PHP Net_IPv6::Uncompress怎么用?PHP Net_IPv6::Uncompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_IPv6
的用法示例。
在下文中一共展示了Net_IPv6::Uncompress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _ip2Bin
/**
* Converts an IPv6 address from Hex into Binary representation.
*
* @param String $ip the IP to convert (a:b:c:d:e:f:g:h),
* compressed IPs are allowed
*
* @return String the binary representation
* @access private
@ @since 1.1.0
*/
protected static function _ip2Bin($ip)
{
$binstr = '';
$ip = Net_IPv6::removeNetmaskSpec($ip);
$ip = Net_IPv6::Uncompress($ip);
$parts = explode(':', $ip);
foreach ($parts as $v) {
$str = base_convert($v, 16, 2);
$binstr .= str_pad($str, 16, '0', STR_PAD_LEFT);
}
return $binstr;
}
示例2: SplitV64
/**
* Splits an IPv6 adress into the IPv6 and a possible IPv4 part
*
* RFC 2373 allows you to note the last two parts of an IPv6 adress as
* an IPv4 compatible adress
*
* Example: 0:0:0:0:0:0:13.1.68.3
* 0:0:0:0:0:FFFF:129.144.52.38
*
* @access public
* @static
* @param string $ip a valid IPv6-adress (hex format)
* @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
*/
function SplitV64($ip)
{
$ip = Net_IPv6::Uncompress($ip);
if (strstr($ip, '.')) {
$pos = strrpos($ip, ':');
$ip[$pos] = '_';
$ipPart = explode('_', $ip);
return $ipPart;
} else {
return array($ip, "");
}
}