本文整理汇总了PHP中Net_IPv6::parseaddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IPv6::parseaddress方法的具体用法?PHP Net_IPv6::parseaddress怎么用?PHP Net_IPv6::parseaddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_IPv6
的用法示例。
在下文中一共展示了Net_IPv6::parseaddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseIpAddress
/**
* parse IP address
*
* IP must be in CIDR format - '192.168.0.50/16'
*/
function parseIpAddress($ip, $mask)
{
/* IPv4 address */
if (IdentifyAddress($ip) == "IPv4") {
require 'PEAR/Net/IPv4.php';
$Net_IPv4 = new Net_IPv4();
$net = $Net_IPv4->parseAddress($ip . '/' . $mask);
$out['network'] = $net->network;
// 192.168.0.0
$out['ip'] = $net->ip;
// 192.168.0.50
$out['broadcast'] = $net->broadcast;
// 192.168.255.255
$out['bitmask'] = $net->bitmask;
// 16
$out['netmask'] = $net->netmask;
// 255.255.0.0
} else {
require 'PEAR/Net/IPv6.php';
$Net_IPv6 = new Net_IPv6();
$out['network'] = $ip;
// 2a34:120:feel::
$out['bitmask'] = $mask;
// 48
$out['netmask'] = $mask;
// 48 - we just duplicate it
//broadcast - we fake it with highest IP in subnet
$net = $Net_IPv6->parseaddress($ip . '/' . $mask);
$out['broadcast'] = $net['end'];
// 2a34:120:feel::ffff:ffff:ffff:ffff:ffff
}
return $out;
}
示例2: parseIpAddress
/**
* parse IP address
*
* IP must be in CIDR format - '192.168.0.50/16'
*/
function parseIpAddress($ip, $mask)
{
/* IPv4 address */
if (IdentifyAddress($ip) == "IPv4") {
// <eNovance>
// Changed to require_once, since it was causing errors when called in a loop
require_once dirname(__FILE__) . '/PEAR/Net/IPv4.php';
$Net_IPv4 = new Net_IPv4();
// </eNovance>
$net = $Net_IPv4->parseAddress($ip . '/' . $mask);
$out['network'] = $net->network;
// 192.168.0.0
$out['ip'] = $net->ip;
// 192.168.0.50
$out['broadcast'] = $net->broadcast;
// 192.168.255.255
$out['bitmask'] = $net->bitmask;
// 16
$out['netmask'] = $net->netmask;
// 255.255.0.0
} else {
require 'PEAR/Net/IPv6.php';
$Net_IPv6 = new Net_IPv6();
$out['network'] = $ip;
// 2a34:120:feel::
$out['bitmask'] = $mask;
// 48
$out['netmask'] = $mask;
// 48 - we just duplicate it
//broadcast - we fake it with highest IP in subnet
$net = $Net_IPv6->parseaddress($ip . '/' . $mask);
$out['broadcast'] = $net['end'];
// 2a34:120:feel::ffff:ffff:ffff:ffff:ffff
}
return $out;
}