krak/luhn
Composer 安装命令:
composer require krak/luhn
包简介
Luhn Algorithm Library
README 文档
README
Luhn mod10 algorithms
Install
composer require krak/luhn
Usage
<?php
use function Krak\Luhn\luhn_validate,
Krak\Luhn\luhn_checksum;
$ccnumber = '79927398713';
var_dump(luhn_validate($ccnumber));
// bool(true)
var_dump(luhn_checksum(substr($ccnumber, 0, -1)));
// int(67)
API
bool luhn_validate($number_string);
int luhn_checksum($number_string);
luhn_validate takes a numeric string and performs a mod10 check on it and verifies if it matches or not.
luhn_checksum takes a numeric string and returns the luhn checksum of it. This is used internally by the luhn_validate to compare a string with its last digit.
Test
You can run tests with peridot using make
make test
统计信息
- 总下载量: 59
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-04-16