PHP ID Number Check class instance, PHP ID number Instance _php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.