Let’s look at the code directly. It’s a very simple PHP class
Copy the code The code is as follows:
$IDCard = new IDCard();
var_dump($IDCard::isCard($_GET['card']));
/**
* ID card processing class
*/
class IDCard {
//Verify whether the ID card is correct
public static function isCard($card) {
$card = self::to18Card($card);
if (strlen($card) != 18) {
; == strtoupper(substr($card, 17, 1)));
}
//Format the 15-digit ID number to 18 digits
public static function to18Card($ card) {
$card = trim($card);
if (strlen($card) == 18) {
return $card;
}
if (strlen($card) != 15) {
Encoding
if (array_search(substr($card, 12, 3), array('996', '997', '998', '999')) !== false) { . ($card, 6, 9);
Calculate the ID card verification code according to the national standard gb 11643-1999
private static function getVerifyNum($cardBase) {
if (strlen($cardBase) != 17) {
return false;
}
// Weighting factor
$factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2) ;
Corresponding value of the verification code '5', '4', '3', '2');
$checksum = 0;
for ($i = 0; $i < strlen($cardBase); $i++ ) {
$checksum += substr($cardBase, $i, 1) * $factor[$i]; = $verify_number_list[$mod];
return $verify_number;
http://www.bkjia.com/PHPjc/824992.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/824992.html
TechArticle
Let’s look at the code directly. A very simple PHP class copy code is as follows: ?php $IDCard = new IDCard( ); var_dump($IDCard::isCard($_GET['card'])); /*** ID card processing class*/ class IDC...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn