1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
function isChineseName($name) { if (preg_match('/^([\xe4-\xe9][\x80-\xbf]{2}){2,4}$/', $name)) { return true; } else { return false; } }
function isBanknumByLuhm($banknum) { $n = 0; for ($i = strlen($banknum); $i >= 1; $i--) { $index=$i-1; if ($i % 2==0) { $n += $banknum{$index}; } else { $t = $banknum{$index} * 2; if ($t > 9) { $t = (int)($t/10)+ $t%10; } $n += $t; } } return ($n % 10) == 0; }
function isIdcard($idcard){ if(strlen($idcard)==18){ return $this->idcard_checksum18($idcard); }elseif((strlen($idcard)==15)){ $idcard = $this->idcard_15to18($idcard); return $this->idcard_checksum18($idcard); }else{ return false; } }
function idcard_verify_number($idcard_base) { if(strlen($idcard_base)!=17){ return false; } $factor=array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2); $verify_number_list=array('1','0','X','9','8','7','6','5','4','3','2'); $checksum=0; for ($i=0; $i<strlen($idcard_base); $i++) { $checksum += substr($idcard_base, $i, 1) * $factor[$i]; } $mod = $checksum % 11; $verify_number = $verify_number_list[$mod]; return $verify_number; }
function idcard_15to18($idcard) { if (strlen($idcard) != 15) { return false; } else { if (array_search(substr($idcard,12,3), array('996','997','998','999')) !== false) { $idcard = substr($idcard,0,6).'18'.substr($idcard,6,9); }else{ $idcard = substr($idcard,0,6).'19'.substr($idcard,6,9); } } $idcard = $idcard.$this->idcard_verify_number($idcard); return $idcard; }
function idcard_checksum18($idcard){ if (strlen($idcard)!=18) { return false; } $idcard_base = substr($idcard,0,17); if ($this->idcard_verify_number($idcard_base) != strtoupper(substr($idcard,17,1))) { return false; } else { return true; } }
function isEmail($email) { $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i"; if (preg_match($pattern, $email)) { $reply = "您输入的电子邮件地址合法<br /><br />\n"; $user_name = preg_replace($pattern ,"$1", $email); $domain_name = preg_replace($pattern ,"$2", $email); $reply .= "用户名:".$user_name."<br />\n"; $reply .= "域名:".$domain_name."<br />\n\n"; return true; } else { $reply = "您输入的电子邮件地址不合法"; return false; } }
|