本篇文章给大家谈谈php年份转生肖,以及php指什么生肖对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、求 php写生肖 1000年到3000年 用swich语句 谢谢2、php 自动计算12生肖3、html输入年份求属相,在窗体应用程序中怎么输出年份然后显示生肖,求代4、输出指定年份的生肖用户php编写代码程序求 php写生肖 1000年到3000年 用swich语句 谢谢
?php
/*
//这个是简单的程序,不用switch
$shuxiang = array(猴,鸡,狗,猪,鼠,牛,虎,兔,龙,蛇,马,羊);
for($i=1000;$i=3000;$i++){
$tmp = $i % 12;
echo $i.$shuxiang[$tmp];
echo hr /;
}*/
for($i=1000;$i=3000;$i++){
$tmp = $i % 12;
switch($tmp){
case 0:
echo $i.":猴";
echo hr /;
break;
case 1:
echo $i.":鸡";
echo hr /;
break;
case 2:
echo $i.":狗";
echo hr /;
break;
case 3:
echo $i.":猪";
echo hr /;
break;
case 4:
echo $i.":鼠";
echo hr /;
break;
case 5:
echo $i.":牛";
echo hr /;
break;
case 6:
echo $i.":虎";
echo hr /;
break;
case 7:
echo $i.":兔";
echo hr /;
break;
case 8:
echo $i.":龙";
echo hr /;
break;
case 9:
echo $i.":蛇";
echo hr /;
break;
case 10:
echo $i.":马";
echo hr /;
break;
case 11:
echo $i.":羊";
echo hr /;
break;
}
}
?
php 自动计算12生肖
?php
//2002/10/23--出生年月
/*
计算12个星座
计算12个生肖
计算年龄
*/
class timeage
{
public $y = 0;
public $m = 0;
public $d = 0;
public $age = 0;
public $time = 0;
public function __construct($time)
{
$this-time = $time;
$this-y = date(Y,$this-time);
$this-m = date(m,$this-time);
$this-d = date(d,$this-time);
}
public function getage()
{
$this-age = time() - $this-time;
$this-age = $this-age/60/60/24/365;
return (int)$this-age;
}
public function getconstellation()
{
switch ($this-m)
{
case 1:
if ($this-d 19)
{
$this-constellation = 摩羯座;
return $this-constellation;
}
else
{
$this-constellation = 水瓶座;
return $this-constellation;
}
break;
case 2:
if ($this-d 18)
{
$this-constellation = 水瓶座;
return $this-constellation;
}
else
{
$this-constellation = 双鱼座;
return $this-constellation;
}
break;
case 3:
if ($this-d 20)
{
$this-constellation = 双鱼座;
return $this-constellation;
}
else
{
$this-constellation = 白羊座;
return $this-constellation;
}
break;
case 4:
if ($this-d 19)
{
$this-constellation = 白羊座;
return $this-constellation;
}
else
{
$this-constellation = 金牛座;
return $this-constellation;
}
break;
case 5:
if ($this-d 20)
{
$this-constellation = 金牛座;
return $this-constellation;
}
else
{
$this-constellation = 双子座;
return $this-constellation;
}
break;
case 6:
if ($this-d 21)
{
$this-constellation = 双子座;
return $this-constellation;
}
else
{
$this-constellation = 巨蟹座;
return $this-constellation;
}
break;
case 7:
if ($this-d 22)
{
$this-constellation = 巨蟹座;
return $this-constellation;
}
else
{
$this-constellation = 狮子座;
return $this-constellation;
}
break;
case 8:
if ($this-d 22)
{
$this-constellation = 狮子座;
return $this-constellation;
}
else
{
$this-constellation = 处女座;
return $this-constellation;
}
break;
case 9:
if ($this-d 22)
{
$this-constellation = 处女座;
return $this-constellation;
}
else
{
$this-constellation = 天秤座;
return $this-constellation;
}
break;
case 10:
if ($this-d 23)
{
$this-constellation = 天秤座;
return $this-constellation;
}
else
{
$this-constellation = 天蝎座;
return $this-constellation;
}
break;
case 11:
if ($this-d 22)
{
$this-constellation = 天蝎座;
return $this-constellation;
}
else
{
$this-constellation = 射手座;
return $this-constellation;
}
break;
case 12:
if ($this-d 20)
{
$this-constellation = 射手座;
return $this-constellation;
}
else
{
$this-constellation = 摩羯座;
return $this-constellation;
}
break;
}
}
public function getzodiac()
{
$this-animals = array(鼠, 牛, 虎, 兔, 龙, 蛇,马, 羊, 猴, 鸡, 狗, 猪);
$this-zodiac = ($this-y - 1900) % 12;
return $this-animals[$this-zodiac];
}
}
$age = strtotime(1993-07-25);
echo $age;
$a = new timeage($age);
echo br;
echo $a-y;
echo br;
echo $a-m;
echo br;
echo $a-d;
echo br;
echo $a-time;
echo br;
echo $a-age;
echo br;
echo $a-getage();
echo br;
echo $a-getconstellation();
echo br;
echo $a-getzodiac();
//没事干替你写了个全部的功能函数 写代码类 记得给好评
html输入年份求属相,在窗体应用程序中怎么输出年份然后显示生肖,求代
提起html输入年份求属相,大家都知道,有人问输入年份,判断该年的生肖,另外,还有人想问怎么用年份推算生肖?求方法,你知道这是怎么回事?其实编写程序,输入一个年份,判断该年属相.(提示switch-…,下面就一起来看看在窗体应用程序中怎么输出年份然后显示生肖,求代码,希望能够帮助到大家!
html输入年份求属相
这个可以用取模的方式实现。主要思路如下:
dimyearasinteger
dimremasinteger
year=val(inputbox(“请输入年份”))
rem=
selectcaserem
case0
msgbox”猴”
case1
msgbox”鸡”
case2
msgbox”狗”
case3
msgbox”猪”
case4
msgbox”鼠”
case5
msgbox”牛”
编写程序,输入一个年份,判断该年属相.(提示switch-…
case6
msgbox”虎”
case7
msgbox”兔”
case8
msgbox”龙”
case9
msgbox”蛇”
msgbox”马”
msgbox”羊”
endselect
主要代码就是这样了,你在根据要修改完善下就可以了
html输入年份求属相:输入年份,判断该年的生肖
这个答案是:牛
属牛人的性格优点:①勤奋努力,有强烈的进取心;②忠厚老实,务实,责任心强,有耐力;③有正义感,爱打抱不平;
④勤俭持家,稳定。
属牛人的性格弱点:稍微固执已见,缺乏通融;有时钻”牛角尖”主观独断
属牛人的性格详解:从出生时辰对属牛人人生的影响来看,白天出生的安静的夜晚出生的牛更积极、更好斗。与此相仿,夏天出生的冬天出生的牛生活更、更富有。
PHP输入年份查询属相的代码。
PHP通过年份查询属相示例代码如下,具体逻辑体现在代码中。
//判断是否为日期格式,默认时间格式为Y-m-d
function is_date($dateStr,$fmt=”Y-m-d”){
$dateArr = explode(“-“,$dateStr);
if(empty($dateArr)){
return false;
}
foreach($dateArr as $val){
if(strlen($val)2){
$val=”0″.$val;
}
$newArr[]=$val;
}
$dateStr =implode(“-“,$newArr);
$unixTime=strtotime($dateStr);
$checkDate= date($fmt,$unixTime);
if($checkDate==$dateStr)
return true;
else
return false;//通过出生年月获取属相
function getShuXiang($bithdayDate){
//判断输入日期格式
if(!is_date($bithdayDate)){
echo “日期输入错误,请检查!”;
}
//年是鼠年
$data = array(‘鼠’,’牛’,’虎’,’兔’,’龙’,’蛇’,’马’,’羊’,’猴’,’鸡’,’狗’,’猪’);
$index = ($bithdayDate-)%12;
return $data[$index];echo “属相:”.getShuXiang(“-05-19”);
//属相:蛇
?
以上就是与在窗体应用程序中怎么输出年份然后显示生肖,求代码相关内容,是关于输入年份,判断该年的生肖的分享。看完html输入年份求属相后,希望这对大家有所帮助!
输出指定年份的生肖用户php编写代码程序
function sx($year) {
$i = ($year % 12) - 3;
$i = $i 0 ? $i + 12 : $i;
switch ($i){
case 1:
return "鼠";
break;
case 2:
return "牛";
break;
case 3:
return "虎";
break;
case 4:
return "兔";
break;
case 5:
return "龙";
break;
case 6:
return "蛇";
break;
case 7:
return "马";
break;
case 8:
return "羊";
break;
case 9:
return "猴";
break;
case 10:
return "鸡";
break;
case 11:
return "狗";
break;
case 0:
return "猪";
break;
}
}
关于php年份转生肖和php指什么生肖的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。