Home  >  Article  >  php教程  >  一个身份证号码检查类

一个身份证号码检查类

PHP中文网
PHP中文网Original
2016-05-25 17:15:191180browse


<?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;$iidx[$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;
				// 导入检查公式 END
            }
			else
				return 0;
        }

	}

?>

                   

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