PHP code example of hsliukangle / card-tool

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

    

hsliukangle / card-tool example snippets




CardTool\CardDb;
use \CardTool\CardToolException;

$card_number = "123";   //银行卡号

try {
    $cardDb = new CardDb();
    
    //获取银行列表
    $bankList = $cardDb->getBankList();
    //var_export($bankList);
    
    //获取卡的信息
    $bank_info = $cardDb->getBankInfo($card_number);

    $result = [
        'is_exists' => $bank_info->isExists(),
        'bank_id' => $bank_info->getBankId(),
        'bank_name' => $bank_info->getBankName(),
        'card_name' => $bank_info->getCardName(),
        'type' => $bank_info->getType(),
        'color' => $bank_info->getColor(),
        'bank_image' => $bank_info->getBankImage(),
        // ... 可自己扩展
    ];

    var_export($result);

} catch (CardToolException $e) {
    print_r($e->getMessage());
}