= 0; $i--) { $vSubStr = substr($vStr, 17 - $i, 1); $vSum += (pow(2, $i) % 11) * (($vSubStr == 'a') ? 10 : intval($vSubStr, 11)); } if ($vSum % 11 != 1) return false; } return true; } /** * 是否手机号 */ public static function isMobile($user_mobile) { $chars = "/^((\(\d{2,3}\))|(\d{3}\-))?1(3|4|5|6|7|8|9)\d{9}$/"; if (preg_match($chars, $user_mobile)) { return true; } else { return false; } } /** * 根据生日获取年龄 */ public static function getAgeByBirth($birthday) { if (empty($birthday)) { return '未知'; } //格式化出生时间年月日 $byear = date('Y', $birthday); $bmonth = date('m', $birthday); $bday = date('d', $birthday); //格式化当前时间年月日 $tyear = date('Y'); $tmonth = date('m'); $tday = date('d'); //开始计算年龄 $age = $tyear - $byear; if ($bmonth > $tmonth || $bmonth == $tmonth && $bday > $tday) { $age--; } return $age; } /** * 获取加密姓名 */ public static function getEncodeName($name) { $len = mb_strlen($name,'utf-8'); $res = mb_substr($name,0,1); for ($i = 1; $i < $len; $i++) { $res .= '*'; } return $res; } }