204
GitHub - ofcold/identity-card: A simple proof of identity card of the people&...
source link: https://github.com/ofcold/identity-card
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
China (region) citizen ID card tool
Simplified Chinese Documentation
China (Mainland) ID card package, the data from the national standard
GB/T 2260-2007
(People's Republic of China administrative divisions code standard).
Installing
composer require ofcold/identity-card
Instructions
A component based on People's Republic of China citizen ID card to obtain the user information.This works for any php framework, but only if the php version is greater than 7.1.
Useing
Verify your Chinese ID card
// Result false OR Ofcold\IdentityCard\IdentityCard instance. $result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081'); if ( $result === false ) { return 'Your ID number is incorrect'; } print_r($result->toArray());
OR test file.
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 'Your ID number is incorrect'; } $area = $idCard->getArea(); $gender = $idCard->getGender(); $birthday = $idCard->getBirthday(); $age = $idCard->getAge(); $constellation = $idCard->getConstellation();
Results:
{ "area": "shan xi sheng yun cheng di qu yun cheng shi", "province": "shan xi sheng", "city": "yun cheng di qu", "county": "yun cheng shi", "gender": "Male", "birthday": "1980-03-12", "age": 38, "constellation": "Pisces" }
Api
- getArea() : string
Get Area
- getConstellation() : string
Get constellation
- getAge() : int
Get age
- getBirthday(string $foramt = 'Y-m-d') : string
Get birthday
- getGender() : string
Get gender
- getCounty() : string|null
Get county
- getCity() : string|null
Get city
- getProvince() : string|null
Get province
- toArray() : array
Get all information.
- toJson(int $option) : string
Json format all information
- __get() : mixed
- __toString() : toJson
CHANGELOG
V2.0.0
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK