[English Documentation](https://github.com/ofcold/identity-card/blob/2.0/README.md)
中國(大陸地區)公民身份證,數據來源於國家標準GB/T 2260-2007 (中華人民共和國行政區劃代碼)
composer require ofcold/identity-card
一個基於中華人民共和國公民身份證的組件能夠獲取用戶信息。這個適用於任何php框架,可是隻有當php版本>=7.1時才能夠。php
// 返回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": "雙魚座" }
獲取地區
獲取星座
獲取生肖
獲取年齡
獲取生日
獲取性別
獲取縣城
獲取城市
獲取省
所有信息
所有信息
V2.0.0git