21 Star 106 Fork 26

Bill li / identity-card

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

一个简单的身份证号码获取用户信息工具


English Documentation


中国(大陆地区)公民身份证,数据来源于国家标准GB/T 2260-2007 (中华人民共和国行政区划代码)


## 安装

    composer require ofcold/identity-card

说明

一个基于中华人民共和国公民身份证的组件可以获取用户信息。这个适用于任何php框架,但是只有当php版本>=7.1时才可以。

使用

验证你的身份证号码


    //  返回false 或 Ofcold\IdentityCard\IdentityCard
    $result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081');

    if ( $result === false ) {

        return '您的身份证号码不正确';
    }

    print_r($result->toArray());

或运行测试文件

    php test
$idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'en');
//  Use locale, Current supported zh-cn,en
// $idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'zh-cn');
if ( $idCard === false ) {

    return '您的身份证号码不正确';
}

$area = $idCard->getArea();
$gender = $idCard->getGender();
$birthday = $idCard->getBirthday();
$age = $idCard->getAge();
$constellation = $idCard->getConstellation();

返回结果:

{
    "area": "山西省 运城地区 运城市",
    "province": "山西省",
    "city": "运城地区",
    "county": "运城市",
    "gender": "男",
    "birthday": "1980-03-12",
    "zodiac": "猪",
    "age": 38,
    "constellation": "双鱼座"
}

Api

  • getArea():string 获取地区
  • getConstellation():string 获取星座
  • getZodiac() : string 获取生肖
  • getAge():int 获取年龄
  • getBirthday(string $foramt = 'Y-m-d'):string 获取生日
  • getGender():string 获取性别
  • getCounty():string|null 获取县城
  • getCity():string|null 获取城市
  • getProvince():string|null 获取省
  • toArray():array 全部信息
  • toJson(int $option):string 全部信息

修改历史

V2.0.0

  • 新增 #2 __get()
  • 新增 #2 __toString()
  • 修改 #2 static make() 方法返回当前对象或者boolean类型
  • 移除 #2 构造方法异常验证
MIT License Copyright (c) 2017 Ofcold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个简单的身份证号码获取用户信息工具 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/git-ofcold-rep/identity-card.git
git@gitee.com:git-ofcold-rep/identity-card.git
git-ofcold-rep
identity-card
identity-card
master

搜索帮助

14c37bed 8189591 565d56ea 8189591