ホームページ  >  記事  >  バックエンド開発  >  PHP は誕生日を要求します

PHP は誕生日を要求します

WBOY
WBOYオリジナル
2016-06-20 12:43:22926ブラウズ

function getAge($birthday) {
$age = 0;
$year = $month = $day = 0;
if (is_array($birthday)) {
extract($birthday);
} else {
if (strpos($birthday, '-') !== false) {
list($year, $month, $day) =explode(' -', $birthday);
$day = substr($day, 0, 2);
}
}
$age = date('Y') - $year;
if (date('m') return $age;
}


/ **
* 年齢を計算します
* @param $args
* @return number: 現在の年齢を返します
*/
プライベート関数 getAge($birthyear,$birthday){
$year = date("Y");
$date = date('md');
$add_age = $誕生日 < $日付 ? 0 : -1;
$age = $year - $birthyear + $add_age;
if($age $age = 18;
}
return $age ;
}

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。