PHP ID Number Check class instance, PHP ID number instance
This article describes the PHP ID number check class. Share to everyone for your reference. Specific as follows:
<?php class Cidmaker//Declare an ID number check class { var $id; var $err; var $idx = array (1,1,1,1,1,1,1,1,3,1,1,2,2,2,3,2,2,2,2,2,2,2,3,3,3,3); var $idy = array (0,1,2,3,4,5,6,7,4,8,9,0,1,2,5,3,4,5,6,7,8,9,0,1,2,3); function check ($id _no) { $id _no = Ucfirst ($id _no),//capitalize the English letter if (ereg ("^[a-z][0-9]{9}$", $id _no)) { For ($i =0; $i <10; $i + +) $ch [$i] = substr ($id _no, $i, 1); $i = 0; Convert the English letter to a digital BEGIN for ($char = "A"; $char! = $ch [0]; $char + +) $i + +; Convert English letter to digital END //import Check formula BEGIN $id = $this->idx[$i]+ $this->idy[$i]*9+ $ch [1]*8+ $ch [2]*7+ $ch [3]*6+$ ch[4]*5+ $ch [5]*4+ $ch [6]*3+ $ch [7]*2+ $ch [8]*1+ $ch] [9]*1; $id = (($id% 10) = = 0)? True:false; return $id; Import Check formula END } else return 0;} }? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1019062.html www.bkjia.com true http://www.bkjia.com/PHPjc/1019062.html techarticle PHP ID Number Check class instance, PHP ID Number Example This article describes the PHP ID number check class. Share to everyone for your reference. Specific as follows: PHP class Cidmaker ...