本文章来给大家总结了一些常用的php根据出生日期计算年龄 生肖 星座程序,希望给各位同学所有帮助了。
例1
代码如下 | 复制代码 |
function getAge($birthday) { if (is_array($birthday)) { $age = date('Y') - $year; |
例2
代码如下 | 复制代码 |
|
根据生日计算年龄 星座 生肖
水瓶座'=>'(1/22-2/21)', '双鱼座'=>'(2/22-3/21)',
'白羊座'=>'(3/22-4/21)', '金牛座'=>'(4/22-5/21)',
'双子座'=>'(5/22-6/21)', '巨蟹座'=>'(6/22-7/21)',
'狮子座'=>'(7/22-8/21)', '处女座'=>'(8/22-9/21)',
'天秤座'=>'(9/22-10/21)', '天蝎座'=>'(10/22-11/21)',
'射手座'=>'(11/22-12/21)', '摩羯座'=>'(12/22-1/21)'
代码如下 | 复制代码 |
[font=Arial] [font=Arial]/** * 根据生日中的月份和日期来计算所属星座 * * @param int $birth_month * @param int $birth_date * @return string */ function get_constellation($birth_month,$birth_date) { //判断的时候,为避免出现1和true的疑惑,或是判断语句始终为真的问题,这里统一处理成字符串形式 $birth_month = strval($birth_month);
$constellation_name = array( '水瓶座','双鱼座','白羊座','金牛座','双子座','巨蟹座', '狮子座','处女座','天秤座','天蝎座)','射手座','摩羯座' );
if ($birth_date { if ('1' !== $birth_month) { $constellation = $constellation_name[$birth_month-2]; } else { $constellation = $constellation_name[11]; } } else { $constellation = $constellation_name[$birth_month-1]; }
return $constellation; }[/font]
[font=Arial]/** * 根据生日中的年份来计算所属生肖 * * @param int $birth_year * @return string */ function get_animal($birth_year) { //1900年是子鼠年 $animal = array( '子鼠','丑牛','寅虎','卯兔','辰龙','巳蛇', '午马','未羊','申猴','酉鸡','戌狗','亥猪' );
$my_animal = ($birth_year-1900)%12; return $animal[$my_animal]; }[/font] |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version
Recommended: Win version, supports code prompts!