PHP做星座属相查询(查询个人星座)

admin 42 0

本文目录一览:

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做星座属相查询(查询个人星座)-第1张图片-星缘配

php星座配对查询怎么做出来的

form action="" method="post"

名字:input type="text" name="text"/

input type="submit" name="submit" value="查询"/

form

hr

?php$conn = mysql_connect(localhost,root,)

or die('没有连接');

$db = mysql_select_db(test,$conn) or die('没有数据库');

mysql_query("set names utf8");

if(isset($_POST['submit'])){

$name=$_POST['text'];

$sql="select * from ttt where name=".$name."";$tt=mysql_query($sql);if($tt){

$row = mysql_fetch_assoc($tt);

echo "名字:".$row[name]."年龄:".$row[age]."/br";

}else{

return false;

}

}

其中:我的数据库帐号是root 密码是 数据库是test 表名是ttt 表中有三个字段 分别是id(主键 自增 ) name age 主要实现功能是你输入一个名字 点击查询它会把这个人的信息就是名字和年龄显示出来

用php 输入日期可以判断星座

$s=5.26;

if($s=3.21  $s=4.19){

    echo '你是白羊座';

}elseif($s=4.20  $s=5.20){

    echo '你是金牛座';

}elseif($s=5.21  $s=6.21){

    echo '你是双子座';

}elseif($s=6.22  $s=7.22){

    echo '你是巨蟹座';

}elseif($s=7.23  $s=8.22){

    echo '你是狮子座';

}elseif($s=8.23  $s=9.22){

    echo '你是处女座';

}elseif($s=9.23  $s=10.23){

    echo '你是天秤座';

}elseif($s=10.24  $s=11.22){

    echo '你是天蝎座';

}elseif($s=11.23  $s=12.21){

    echo '你是射手座';

}elseif($s=12.22  $s=1.19){

    echo '你是魔羯座';

}elseif($s=1.20  $s=2.18){

    echo '你是水平座';

}elseif($s=2.19  $s=3.20){

    echo '你是双鱼座';

}

如何用php根据出生日期计算年龄和星座

?php

function calcAge($birthday) {

    $age = 0;

    $signs = array( array('20' = '宝瓶座'), array('19' = '双鱼座'), array('21' = '白羊座'), array('20' = '金牛座'), array('21' = '双子座'), array('22' = '巨蟹座'), array('23' = '狮子座'), array('23' = '处女座'), array('23' = '天秤座'), array('24' = '天蝎座'), array('22' = '射手座'), array('22' = '摩羯座'));

    if (!empty($birthday)) {

        $age = strtotime($birthday);

        if ($age === false) {

            return 0;

        }

        list($y1, $m1, $d1) = explode("-", date("Y-m-d", $age));

        list($y2, $m2, $d2) = explode("-", date("Y-m-d"), time());

        $age = $y2 - $y1;

        //下面是判断月份大小,如果只是逄年份的可以去掉,如果算上月份的话,比如:2000年4月1日,那算出来是16算,要到了4月,算出来才是17岁

        if ((int)($m2 . $d2)  (int)($m1 . $d1)) {

            $age -= 1;

        }

        //星座

        $key = (int)$m1 - 1;

        list($startSign, $signName) = each($signs[$key]);

        if ($d1  $startSign) {

            $key = $m1 - 2  0 ? $m1 = 11 : $m1 -= 2;

            list($startSign, $signName) = each($signs[$key]);

        }

        //return $signName;

    }

    return $age.$signName;

}

echo calcAge("2011-4-31");

?

标签: PHP做星座属相查询

发表评论 (已有0条评论)

还木有评论哦,快来抢沙发吧~