理由如下:
PHP(超文本預處理器)主要用來計算信用卡等證件號碼的合法性。
1、從卡號最後壹位數字開始,偶數位乘以2,如果乘以2的結果是兩位數,將兩個位上數字相加保存,把所有數字相加,得到總和,如果信用卡號碼是合法的,總和可以被10整除(
參考資料:
2、PHP實現的根據銀行卡號判斷是哪個銀行的方法:
(
參考資料:
bankList.php的內容會寫在下面。請全選其中所有數據後,另存為bankList.php文件使用。
header('Content-type:text/html;charset=utf-8');
require_once('bankList.php');
function bankInfo($card,$bankList)
{
$card_8 = substr($card, 0, 8);
if (isset($bankList[$card_8])) {
echo $bankList[$card_8];
return;
}
$card_6 = substr($card, 0, 6);
if (isset($bankList[$card_6])) {
echo $bankList[$card_6];
return;
}
$card_5 = substr($card, 0, 5);
if (isset($bankList[$card_5])) {
echo $bankList[$card_5];
return;
}
$card_4 = substr($card, 0, 4);
if (isset($bankList[$card_4])) {
echo $bankList[$card_4];
return;
}
echo '該卡號信息暫未錄入';
}
bankInfo('6228481552887309119',$bankList);
//-------------以下內容是bankList.php的內容,請全選以下所有內容,另存為bankList.php文件使用。--------
<?php
$bankList = [
'621098' => '郵儲銀行-綠卡通-借記卡',
'622150' => '郵儲銀行-綠卡銀聯標準卡-借記卡',
'622151' => '郵儲銀行-綠卡銀聯標準卡-借記卡',
'62316901' => '開縣泰業村鎮銀行-開縣泰業村鎮銀行泰業卡-借記卡',
'62316906' => '東莞厚街華業村鎮銀行-易事通卡-借記卡',
'62361026' => '西安高陵陽光村鎮銀行-金絲路陽光卡-借記卡',
'62361025' => '陜西洛南陽光村鎮銀行-金絲路陽光卡-借記卡',
'62168305' => '江蘇溧水民豐村鎮銀行-金鼎卡-借記卡',
'62335101' => 'CJSC “Spitamen Bank”(30030762)-classic-借記卡',
'62335102' => 'CJSC “Spitamen Bank”(30030762)-gold-借記卡',
'62335103' => 'CJSC “Spitamen Bank”(30030762)-platinum-借記卡',
'62335104' => 'CJSC “Spitamen Bank”(30030762)-diamond-借記卡',
'62335105' => 'CJSC “Spitamen Bank”(30030762)-classic-借記卡',
'62335106' => 'CJSC “Spitamen Bank”(30030762)-gold-借記卡',
'62335107' => 'CJSC “Spitamen Bank”(30030762)-platinum-借記卡',
'62335108' => 'CJSC “Spitamen Bank”(30030762)-diamond-借記卡',
];
//-------------------bankList.php的所有內容到此結束---------------------------