From 9ea73f0da8f053a7b7a686a98c2b59cc59f7c98a Mon Sep 17 00:00:00 2001 From: p7e54f8xs <2054887258@qq.com> Date: Thu, 31 Oct 2024 10:57:50 +0800 Subject: [PATCH] ADD file via upload --- zodiac.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 zodiac.php diff --git a/zodiac.php b/zodiac.php new file mode 100644 index 0000000..160b8fa --- /dev/null +++ b/zodiac.php @@ -0,0 +1,50 @@ +format('n'); + $day = $birthdate->format('j'); + + $westernZodiac = ''; + if (($month == 3 && $day >= 21) || ($month == 4 && $day <= 19)) { + $westernZodiac = '白羊座'; + } elseif (($month == 4 && $day >= 20) || ($month == 5 && $day <= 20)) { + $westernZodiac = '金牛座'; + } elseif (($month == 5 && $day >= 21) || ($month == 6 && $day <= 20)) { + $westernZodiac = '双子座'; + } elseif (($month == 6 && $day >= 21) || ($month == 7 && $day <= 22)) { + $westernZodiac = '巨蟹座'; + } elseif (($month == 7 && $day >= 23) || ($month == 8 && $day <= 22)) { + $westernZodiac = '狮子座'; + } elseif (($month == 8 && $day >= 23) || ($month == 9 && $day <= 22)) { + $westernZodiac = '处女座'; + } elseif (($month == 9 && $day >= 23) || ($month == 10 && $day <= 22)) { + $westernZodiac = '天秤座'; + } elseif (($month == 10 && $day >= 23) || ($month == 11 && $day <= 21)) { + $westernZodiac = '天蝎座'; + } elseif (($month == 11 && $day >= 22) || ($month == 12 && $day <= 21)) { + $westernZodiac = '射手座'; + } elseif (($month == 12 && $day >= 22) || ($month == 1 && $day <= 19)) { + $westernZodiac = '摩羯座'; + } elseif (($month == 1 && $day >= 20) || ($month == 2 && $day <= 18)) { + $westernZodiac = '水瓶座'; + } else { + $westernZodiac = '双鱼座'; + } + + // 计算中国生肖 + $year = $birthdate->format('Y'); + $chineseZodiac = ''; + $zodiacAnimals = ['鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪']; + $chineseZodiac = $zodiacAnimals[($year - 1900) % 12]; + + echo json_encode([ + 'westernZodiac' => $westernZodiac, + 'chineseZodiac' => $chineseZodiac + ]); +} else { + echo json_encode(['error' => '无效的请求']); +} \ No newline at end of file