Skip to content
IdentityCard is class of util including birthday、age、sex、star as well as constellation and so on.
Branch: master
Clone or download
Latest commit 1f94d9a Jul 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sbin feature:query province and city as well as area chinese name by idCar… Jun 24, 2019
src/IdentityCard feature:query province and city as well as area chinese name by idCar… Jun 24, 2019
tests feature:query province and city as well as area chinese name by idCar… Jun 24, 2019
.gitignore 🚀feature:add idCard image create Jun 9, 2019
.php_cs 🚀feature:add idCard image create Jun 9, 2019
.travis.yml 🚀feature:add idCard image create Jun 9, 2019
LICENSE
README.md update:readme Jul 14, 2019
composer.json 🚀feature:add idCard image create Jun 9, 2019
php.php
phpunit.xml version | age birthday sex star constellation Jan 25, 2019

README.md

IdentityCard

中国(大陆)公民身份证类

Latest Stable Version Total Downloads License build status

安装

在项目composer.json添加依赖,如下:

"require": {
        "alicfeng/identity-card": "~3.0"
}

或者直接通过CLI安装,如下:

composer require "alicfeng/identity-card" -vvv

版本更新说明

  • V1.0

    在版本 1.0 中,证件号码错误都是返回false

  • V2.0

    在版本 2.0 中添加异常捕获机制,证件错误将返回异常,只有c::validate($id)方法返回bool值。

  • V2.3

    在版本 2.3 添加了一个新功能,可以提供身份证信息生成身份证图片。

    注意:图片的大小为:865 * 540 px

  • V3.0 - 2019.06.25

    在版本 3.0 添加了根据省份正号码获取省、市、区行政地区中文名称。

    行政地区编码源于中华人民共和国民政部,更新于 2019-06-21


使用

use AlicFeng\IdentityCard\IdentityCard;
use AlicFeng\IdentityCard\Birthday;

$id = 'IdentityCard';

# 获取周岁 | 
$age = IdentityCard::age($id);

# 获取生日
$birthday = IdentityCard::birthday($id);

# 获取性别 | {男为M | 女为F}
$sex = IdentityCard::sex($id);

# 获取生肖
$constellation = IdentityCard::constellation($id);

# 获取星座
$star = IdentityCard::star($id);

# 获取星座
$star = Birthday::star($birthday);

# 获取年龄
$age = Birthday::age($id);

# 生成身份证正面
$front(resource) = IdentityCard::createFrontImage(...);

# 生成身份证反面
$back(resource) = IdentityCard::createBackImage(...);

# 获取省
$province = IdentityCard::privince($id, $default='');

# 获取市
$city = IdentityCard::city($id, $default='');

# 获取区
$area = IdentityCard::area($id, $default='');
You can’t perform that action at this time.