PHP code example of douyasi / identity-card

1. Go to this page and download the library: Download douyasi/identity-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/ */

    

douyasi / identity-card example snippets


Route::get('test', function() {
    $ID = new Douyasi\IdentityCard\ID();
    $pid = '42032319930606629x';
    $passed = $ID->validateIDCard($pid);
    $area = $ID->getArea($pid);
    $gender = $ID->getGender($pid);
    $birthday = $ID->getBirth($pid);
    $age = $ID->getAge($pid);
    $constellation = $ID->getConstellation($pid);
    return compact('passed', 'area', 'gender', 'birthday', 'age', 'constellation');
});

'水瓶座',  // 1.21-2.19 [Aquarius]
'双鱼座',  // 2.20-3.20 [Pisces]
'白羊座',  // 3.21-4.19 [Aries]
'金牛座',  // 4.20-5.20 [Taurus]
'双子座',  // 5.21-6.21 [Gemini]
'巨蟹座',  // 6.22-7.22 [Cancer]
'狮子座',  // 7.23-8.22 [Leo]
'处女座',  // 8.23-9.22 [Virgo]
'天秤座',  // 9.23-10.23 [Libra]
'天蝎座',  // 10.24-11.21 [Scorpio]
'射手座',  // 11.22-12.20 [Sagittarius]
'魔羯座',  // 12.21-1.20 [Capricorn]