php身份证校验码的计算例子
例子
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6427')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6427>public function id_verify($my_id) {
$coefficient = array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2);
$remainder_map = array(1,0,'X',9,8,7,6,5,4,3,2);
$count = 0;
for ($i=0; $i < 17; $i ) {
$count = $my_id[$i] * $coefficient[$i];
}
$remainder = $count % 11;
if ($my_id[17] == $remainder_map[$remainder]){
echo 'true';
}else{
echo 'false';
}
}
使用方法很简单
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy9034')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy9034>$body = '44010221990101001';
id_verify($my_id) //就会有结果输出的哦
您可能感兴趣的文章:
PHP计算身份证校验码示例
PHP 验证身份证号的函数
身份证方面的函数
js 验证身份证信息有效性实例
PHP身份证正则验证(兼容15,18位身份证)代码一例
JS验证身份证有效性的实例代码
php验证身份证号码是否正确函数
PHP根据身份证号码,获取性别、获取生日、计算年龄等多个信息
php身份证校验码的计算例子
PHP检测身份证号码两个函数