private function check_user_info_value() { $nickname = $this->input->post('nickname', TRUE); $headimg = $this->input->post('headimg', TRUE); $signature = $this->input->post('signature', TRUE); $birthday = $this->input->post('birthday', TRUE); $sex = $this->input->post('sex', TRUE); $user = array(); if ($nickname) { $user['nick_name'] = check_empty(trimall(strip_tags($nickname)), FALSE, '1023'); } if ($headimg) { $user['headimg'] = check_empty(trimall(strip_tags($headimg)), FALSE, '1024'); } if ($signature) { $user['signature'] = check_empty(trimall(strip_tags($signature)), FALSE, '1025'); } if ($birthday) { $birthday = check_birthday($birthday); if (!$birthday) { response_code('1022'); } $user['birthday'] = $birthday; } if ($sex) { $user['sex'] = input_string($sex, array('F', 'M'), FALSE, '1021'); } return $user; }
function getAge($birthday) { if (!check_birthday($birthday)) { return ''; } list($year, $month, $day) = explode('-', $birthday); $year = (int) $year; $month = (int) $month; $day = (int) $day; $age = date('Y') - $year; if (date('m') < $month || date('m') == $month && date('d') < $day) { $age--; } return $age; }