定制 hyqo/ip-utils 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hyqo/ip-utils

最新稳定版本:1.0.0

Composer 安装命令:

composer require hyqo/ip-utils

包简介

README 文档

README

Packagist Version Packagist PHP Version Support GitHub Workflow Status

Install

composer require hyqo/ip-utils

Methods

IpInterface::isValid(string $ip): bool;
IpInterface::isMatch(string $ip, string|array $subnets): bool;
IpInterface::normalize(string $ip): string;
IpInterface::port(string $ip): ?int;

Usage

use Hyqo\Utils\Ip\Ip;

Ip::isValid('192.168.1.0'); //true
Ip::isValid('0:0:0:0:0:0:0:1'); //true

Ip::isMatch('131.0.72.199', '131.0.72.0/22'); //true
Ip::isMatch('131.0.76.199', '131.0.72.0/22'); //false

Ip::isMatch('132.0.72.199', ['131.0.72.0/22', '192.168.1.0/31']); //true

Ip::normalize('127.0.0.1:80'); //127.0.0.1
Ip::normalize('[::1]:80'); //::1

Ip::port('127.0.0.1:80'); //80
Ip::port('[::1]:80'); //80

The Ip class automatically detects IP version, but you can use Ipv4 and Ipv6 classes with the same methods as well.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-05