获取身份证信息组件 Identity Card Of China(PHP)

码农软件 · 软件分类 · 常用工具包 · 2019-08-12 18:27:10

软件介绍

Identity Card Of China (PHP)是一个基于「公民身份号码」规则获取公民身份号码中包含的基础信息组件。

安装

  • 你的 PHP 版本应该 >= 7.0

我们使用 Composer 安装:

composer require medz/id-card-of-china

使用

遵循 PHP-MD 原则,这个工具不提供静态调用,所以使用需要进行对象实例化:

use Medz\IdentityCard\China\Identity;

$peopleIDNumber = '350301198906180060';
$peopleIdentity = new Identity($peopleIDNumber);

APIs

基于 Medz\IdentityCard\China\IdentityInterface 实例

  • legal:检查公民身份号码是否合法

  • birthday:获取公民身份号码中包含的生日信息

  • gender:获取身份证包含的性别信息

  • region: 获取身份证包含的地区信息,返回 Medz\IdentityCard\China\Region\RegionInterface 实例

region 对象 APIs

  • code: 获取 GB/T 2260 的地区行政代码

  • province:获取省份名称或者直辖市名称

  • city:获取城市名称,如果是直辖市则返回 ''

  • county:获取区县名称

  • tree:获取地区层级数组

  • treeString:获取地区完整字符串,支持传递一个参数作为省市区的分隔符

演示

use Medz\IdentityCard\China\Identity;

$peopleIDNumber = '350302198906180060';
$peopleIdentity = new Identity($peopleIDNumber);
$peopleRegion = $peopleIdentity->region();

var_dump(
    $peopleIdentity->legal(),    // true | false
    $peopleIdentity->birthday(), // 1989-06-18
    $peopleIdentity->gender(),   // 女 | 男
    $peopleRegion->code(),       // 350302
    $peopleRegion->province(),   // 福建省
    $peopleRegion->city(),       // 莆田市
    $peopleRegion->county(),     // 城厢区
    $peopleRegion->tree(),       // ["福建省", "莆田市", "城厢区"]
    $peopleRegion->treeString(' ') // 福建省 莆田市 城厢区
);

本文地址:https://codercto.com/soft/d/12222.html

The Lean Startup

The Lean Startup

Eric Ries / Crown Business / 2011-9-13 / USD 26.00

更多中文介绍:http://huing.com Most startups fail. But many of those failures are preventable. The Lean Startup is a new approach being adopted across the globe, chan ging the way companies are built and ......一起来看看 《The Lean Startup》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器