判断是否是身份证、通过身份证获取属相、星座、性别

该博客介绍了如何使用PHP进行身份证号码的验证,并根据身份证号码获取对应的属相、星座和性别信息。
摘要由CSDN通过智能技术生成

<?php

// 根据身份证号,自动返回对应的星座

function get_xingzuo($cid) {

 $cid = getIDCard($cid);

  

 if (!isIdCard($cid)) return '';

 $bir = substr($cid,10,4);

 $month = (int)substr($bir,0,2);

 $day = (int)substr($bir,2);

 $strValue = '';

 if (($month == 1 && $day >= 20) || ($month == 2 && $day <= 18)) {

  $strValue = "水瓶座";

 } else if (($month == 2 && $day >= 19) || ($month == 3 && $day <= 20)) {

  $strValue = "双鱼座";

 } else if (($month == 3 && $day > 20) || ($month == 4 && $day <= 19)) {

  $strValue = "白羊座";

 } else if (($month == 4 && $day >= 20) || ($month == 5 && $day <= 20)) {

  $strValue = "金牛座";

 } else if (($month == 5 && $day >= 21) || ($month == 6 && $day <= 21)) {

  $strValue = "双子座";

 } else if (($month == 6 && $day > 21) || ($month == 7 && $day <= 22)) {

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的星座属相测算代码,你可以根据自己的需要进行更改和完善。 ```python # 根据生日计算星座属相 def calculate_constellation_and_zodiac(birthday): # 12个星座分别对应的日期范围 constellation_date_range = [ (1, 21, 2, 19), # 水瓶座 (2, 20, 3, 20), # 双鱼座 (3, 21, 4, 20), # 白羊座 (4, 21, 5, 21), # 金牛座 (5, 22, 6, 21), # 双子座 (6, 22, 7, 22), # 巨蟹座 (7, 23, 8, 23), # 狮子座 (8, 24, 9, 23), # 处女座 (9, 24, 10, 23), # 天秤座 (10, 24, 11, 22), # 天蝎座 (11, 23, 12, 21), # 射手座 (12, 22, 1, 20) # 摩羯座 ] # 12个属相分别对应的起始年份 zodiac_start_year = [ 1900, 1912, 1924, 1936, 1948, 1960, 1972, 1984, 1996, 2008, 2020 ] year, month, day = map(int, birthday.split('-')) # 计算星座 for i in range(len(constellation_date_range)): start_month, start_day, end_month, end_day = constellation_date_range[i] if (month == start_month and day >= start_day) or (month == end_month and day <= end_day) or (start_month < month < end_month): constellation = i break else: constellation = 11 # 默认为摩羯座 # 计算属相 zodiac = (year - zodiac_start_year[0]) % 12 return constellation, zodiac ``` 使用方法: ```python birthday = '1994-02-08' constellation, zodiac = calculate_constellation_and_zodiac(birthday) print(f'星座为{constellation + 1},属相为{zodiac + 1}') ``` 输出结果: ``` 星座为5,属相为10 ``` 说明该生日对应的星座为双子座,属相为蛇。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值