foolz/inet
最新稳定版本:0.6.0
Composer 安装命令:
composer require foolz/inet
包简介
A PHP implementation of decimal IPs. Converts IPs from presentation to decimal and viceversa. Very useful to store IPs in database as numbers instead of string, in example in a decimal(39,0) column.
README 文档
README
This Composer package provides two functions that allow converting between IP Address and IP Decimal. It works for both IPv4 and IPv6.
Based on the answer to "How to convert IPv6 from binary for storage in MySQL?" on StackOverflow by Sander Marechal. Content posted on StackOverflow is under the CC BY-SA 3.0 License.
Requirements
- BCMath
- PHP 5.3+
Usage
$decimal_ip = \Foolz\Inet\Inet::ptod($ip); $ip = \Foolz\Inet\Inet::dtop($decimal_ip);
Storage on MySQL Databases
You should use a DECIMAL(39,0) column to store the entire IP Decimal.
统计信息
- 总下载量: 2.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: CC-BY-SA-3.0
- 更新时间: 2012-09-15