Maison  >  Article  >  développement back-end  >  PHP求周岁

PHP求周岁

WBOY
WBOYoriginal
2016-06-20 12:43:22926parcourir

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:返回当前年龄
     */
    private function getAge($birthyear,$birthday){
        $year = date("Y");
        $date = date('md');
        $add_age = $birthday         $age = $year - $birthyear + $add_age;
        if($age             $age = 18;
        }
        return $age;
    }

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn