项目地址
https://github.com/jxlwqq/id-validator
安装:
composer require “jxlwqq/id-validator”
使用:
验证是否正确:
use Jxlwqq\IdValidator\IdValidator;
$idValidator = new IdValidator();
$res = $idValidator->isValid('440308199901101512'); // 大陆居民身份证 18 位
var_dump($res)//返回bool
获取身份证信息:
$idValidator = new IdValidator();
$res = $idValidator->getInfo('440308199901101512'); // 大陆居民身份证 18 位
echo json_encode($res)//
返回:
{
"addressCode": "440308",
"abandoned": 0,
"address": "广东省深圳市盐田区",
"addressTree": [
"广东省",
"深圳市",
"盐田区"
],
"birthdayCode": "1999-01-10",
"constellation": "摩羯座",
"chineseZodiac": "卯兔",
"sex": 1,
"length": 18,
"checkBit": "2"
}