導航:首頁 > 編程語言 > php計算生肖

php計算生肖

發布時間:2024-08-27 02:39:38

『壹』 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();

//沒事干替你寫了個全部的功能函數 寫代碼類 記得給好評

閱讀全文

與php計算生肖相關的資料

熱點內容
java6webservice 瀏覽:450
硬體加密的未來發展趨勢 瀏覽:589
釘釘上文件夾怎麼做 瀏覽:277
編譯動物之塔 瀏覽:613
玩嘻哈必下的app在哪裡下 瀏覽:210
談談如何給文件夾或文件加密 瀏覽:37
螺桿式壓縮機溫度計 瀏覽:706
gnu編譯器pdf 瀏覽:463
稀有程序員圖片 瀏覽:43
linux系統有哪些版本的 瀏覽:149
黑月編譯器優缺點 瀏覽:685
線刷包為啥要解壓 瀏覽:149
伺服器滑道怎麼安裝 瀏覽:700
手游發貨伺服器是什麼 瀏覽:711
文件夾的各個名稱 瀏覽:724
安卓系統哪個文件夾存放密碼文件 瀏覽:363
傳真伺服器什麼意思 瀏覽:251
stm3251單片機 瀏覽:281
怎麼做程序員男友 瀏覽:828
信道編解碼作用 瀏覽:840