判斷是否成年:
1.判斷年份是否滿18年
2.年份剛好滿18年判斷月份是否大於當前月份;
3.月份相同判斷日期是否大於當前日期
function isAdult(){
$birth_year = 1999;
$birth_month = 12;
$birth_day = 25;
$today_year = 2019;
$today_month = 09;
$today_day = 04;
$adult = 1;//已成年
if($birth_year + 18 <= $today_year ){
if($birth_year + 18 == $today_year ){
if($birth_month <= $today_month )
if($birth_month == $today_month ) $adult = $birth_day > $today_day ? 0 : 1;
else
$adult = 0;
}
}else{
$adult = 0;
}
return $adult == 0 ? FALSE : TRUE;
}
其他業務代碼略
//打完收工w(゚Д゚)w