Home  >  Article  >  Backend Development  >  PHP ID card number checking class example, PHP ID card number example_PHP tutorial

PHP ID card number checking class example, PHP ID card number example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:49:41874browse

php ID card number checking class example, php ID card number example

The example in this article tells about the php ID card number checking class. Share it with everyone for your reference. The details are as follows:

<&#63;php
 class CIDMaker // 声明一个身份证号码检查类
 {
  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); // 将英文字母转大写
   if(ereg("^[A-Z][0-9]{9}$", $id_no))
   {
    for($i=0;$i<10;$i++)
    $ch[$i] = substr($id_no,$i,1);
    $i = 0;
    // 将英文字母转为数字 BEGIN
    for ($char = "A"; $char != $ch[0]; $char++)
     $i++;
    // 将英文字母转为数字 END
    // 导入检查公式 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) &#63; TRUE : FALSE;
    return $id;
    // 导入检查公式 END
   }
   else
    return 0;
  }
 }
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1019062.htmlTechArticlephp ID card number checking class example, php ID card number example This article describes the php ID card number checking class. Share it with everyone for your reference. The details are as follows: php class CIDMaker...
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