PHP code example of uuling / id-card
1. Go to this page and download the library: Download uuling/id-card library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uuling / id-card example snippets
use Uuling\Idcard;
$identity = new Identity();
$identity->setId('******************');
或者
$identity = new Identity('******************');
// 验证身份证号码格式是否正确
$identity->isValidate();
// true 或者 false
// 获取生日,格式YYYY mm dd
$identity->getBirth('-');
// 2015-01-01
$identity->getBirth('/');
// 2015/01/01
// 获取性别
$identity->getGender();
// m
$identity->getGender(Identity::GENDER_CN);
// 男
// 获取区域
$identity->getArea();
// ['province' => '***', 'city' => '***', 'county' => '***']