承接 kseven/ip-tools 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kseven/ip-tools

最新稳定版本:1.0.0

Composer 安装命令:

composer require kseven/ip-tools

包简介

PHP IP Tools for manipulation with IPv4 and IPv6

README 文档

README

Build Status Latest Stable Version Total Downloads Downloads Month License

Universal IP Tools for manipulation on IPv4 and IPv6.

Require this package with Composer

Install this package through Composer. Edit your project's composer.json file to require kseven/ip-tools.

Create composer.json file:

{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "kseven/ip-tools": "~1.1.0"
    }
}

And run composer update

Or run a command in your command line:

composer require kseven/ip-tools

Usage

<?php
    $loader = require __DIR__.'/vendor/autoload.php';

    use KSeven\IPTools\Ip;

    // Validating
    $status = Ip::isValid('192.168.1.1'); // true

    $status = Ip::isValid('192.168.1.256'); // false


    // ip2long, long2ip

    /// IPv4
    $long = Ip::ip2long('192.168.1.1'); // 3232235777

    $dec = Ip::long2ip('3232235777'); // 192.168.1.1

    /// IPv6
    $long = Ip::ip2long('fe80:0:0:0:202:b3ff:fe1e:8329'); // 338288524927261089654163772891438416681

    $dec = Ip::long2ip('338288524927261089654163772891438416681', true); // fe80::202:b3ff:fe1e:8329


    // Matching

    /// IPv4
    $status = Ip::match('192.168.1.1', '192.168.1.*'); // true

    $status = Ip::match('192.168.1.1', '192.168.*.*'); // true

    $status = Ip::match('192.168.1.1', '192.168.*.*'); // true

    $status = Ip::match('192.168.1.1', '192.168.0.*'); // false


    $status = Ip::match('192.168.1.1', '192.168.1/24'); // true

    $status = Ip::match('192.168.1.1', '192.168.1.1/255.255.255.0'); // true

    $status = Ip::match('192.168.1.1', '192.168.0/24'); // false

    $status = Ip::match('192.168.1.1', '192.168.0.0/255.255.255.0'); // false


    $status = Ip::match('192.168.1.5', '192.168.1.1-192.168.1.10'); // true

    $status = Ip::match('192.168.5.5', '192.168.1.1-192.168.10.10'); // true

    $status = Ip::match('192.168.5.5', '192.168.6.1-192.168.6.10');


    $status = Ip::match('192.168.1.1', array('122.128.123.123', '192.168.1.*', '192.168.123.124')); // true

    $status = Ip::match('192.168.1.1', array('192.168.123.*', '192.168.123.124'));

    /// IPv6

    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // true

    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // true

    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652',
                        '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:9999'); // true


    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3258:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // false

    $status = Ip::match('2001:cdba:0000:0000:0000:1234:3258:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // false

    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:7778',
                        '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:7777'); // false

This code is available on Github. Pull requests are welcome.

Troubleshooting

If you like living on the edge, please report any bugs you find on the PHP IP Tools issues page.

Contributing

See CONTRIBUTING.md for information.

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.

Credits

Full credit list in CREDITS

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固