当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_IPv6::parseaddress方法代码示例

本文整理汇总了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;
}
开发者ID:retexica,项目名称:phpipam,代码行数:38,代码来源:functions-network.php

示例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;
}
开发者ID:krys1976,项目名称:phpipam-1,代码行数:41,代码来源:functions-network.php


注:本文中的Net_IPv6::parseaddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。