/*
* 根据身份证号码获取年龄
* inupt $code = 完整的身份证号
* return $age : 年龄
*/
function ageVerification($code){
$age_time = strtotime(substr($code, 6, 8));
if($age_time === false){
return false;
}
list($y1,$m1,$d1) = explode("-",date("Y-m-d",$age_time));
$now_time = strtotime("now");
list($y2,$m2,$d2) = explode("-",date("Y-m-d",$now_time));
$age = $y2 - $y1;
if((int)($m2.$d2) < (int)($m1.$d1)){
$age -= 1;
}
return $age;
}