好得很程序员自学网
  • 首页
  • 后端语言
    • C#
    • PHP
    • Python
    • java
    • Golang
    • ASP.NET
  • 前端开发
    • Angular
    • react框架
    • LayUi开发
    • javascript
    • HTML与HTML5
    • CSS与CSS3
    • jQuery
    • Bootstrap
    • NodeJS
    • Vue与小程序技术
    • Photoshop
  • 数据库技术
    • MSSQL
    • MYSQL
    • Redis
    • MongoDB
    • Oracle
    • PostgreSQL
    • Sqlite
    • 数据库基础
    • 数据库排错
  • CMS系统
    • HDHCMS
    • WordPress
    • Dedecms
    • PhpCms
    • 帝国CMS
    • ThinkPHP
    • Discuz
    • ZBlog
    • ECSHOP
  • 高手进阶
    • Android技术
    • 正则表达式
    • 数据结构与算法
  • 系统运维
    • Windows
    • apache
    • 服务器排错
    • 网站安全
    • nginx
    • linux系统
    • MacOS
  • 学习教程
    • 前端脚本教程
    • HTML与CSS 教程
    • 脚本语言教程
    • 数据库教程
    • 应用系统教程
  • 新技术
  • 编程导航
    • 区块链
    • IT资讯
    • 设计灵感
    • 建站资源
    • 开发团队
    • 程序社区
    • 图标图库
    • 图形动效
    • IDE环境
    • 在线工具
    • 调试测试
    • Node开发
    • 游戏框架
    • CSS库
    • Jquery插件
    • Js插件
    • Web框架
    • 移动端框架
    • 模块管理
    • 开发社区
    • 在线课堂
    • 框架类库
    • 项目托管
    • 云服务

当前位置:首页>CMS系统>Dedecms
<tfoot draggable='sEl'></tfoot>

php计算属相 php怎么求和

很多站长朋友们都不太清楚php计算属相,今天小编就来给大家整理php计算属相,希望对各位有所帮助,具体内容如下:

本文目录一览: 1、 php 自动计算12生肖 2、 如何用php根据出生日期计算年龄和星座 3、 html输入年份求属相,在窗体应用程序中怎么输出年份然后显示生肖,求代 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根据出生日期计算年龄和星座

<?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");

?>

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计算属相的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。

查看更多关于php计算属相 php怎么求和的详细内容...

声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did168478
更新时间:2023-04-11   阅读:44次

上一篇: php本页面跳转 php页面跳转传多个参数

下一篇:php7废弃特性 php7的新特性有哪些

相关资讯

最新资料更新

  • 1.dedecms v5.7提示php.ini register_globals must is Off
  • 2.DEDECMS去除所有自带后门和漏洞的方法(DEDE安装之后需要做的事)
  • 3.Linux下安装DedeCMS及安全设置教程
  • 4.修改dedecms文章标题长度限制的方法
  • 5.详解如何把dedecms数据生成json
  • 6.织梦dedecms配置手机wap站点并绑定二级域名
  • 7.织梦dedecms首页导航栏currentstyle参数无效的替代方法
  • 8.Dedecms图片加上Alt和Title等属性的修改方法
  • 9.织梦dede修改关键字长度的方法
  • 10.DedeCMS的TAG标签无法保存和自动删除的解决方法
  • 11.织梦DEDECMS友情链接出现内页与首页都在首页显示解决方法
  • 12.织梦列表页分页错位(分页显示为竖排)的解决方法
  • 13.详解织梦模板DEDECMS对discuz论坛的一些常用调用代码
  • 14.解析织梦DedeCMS图片按月存放的实现方法
  • 15.织梦去掉上传图片的水印或者改为自己设计的水印
  • 16.dedecms首页调用随机文章及自动更新功能实例
  • 17.织梦dedecms修改任意管理员漏洞处理方法
  • 18.织梦dedecms获取上一篇下一篇文章链接的方法
  • 19.dedecms使用sql语句调用文章静态链接地址的方法
  • 20.织梦模板DEDECMS首页301重定向的代码教程

CopyRight:2016-2025好得很程序员自学网 备案ICP:湘ICP备09009000号-16 http://haodehen.cn
本站资讯不构成任何建议,仅限于个人分享,参考须谨慎!
本网站对有关资料所引致的错误、不确或遗漏,概不负任何法律责任。
本网站刊载的所有内容(包括但不仅限文字、图片、LOGO、音频、视频、软件、程序等)版权归原作者所有。任何单位或个人认为本网站中的内容可能涉嫌侵犯其知识产权或存在不实内容时,请及时通知本站,予以删除。

网站内容来源于网络分享,如有侵权发邮箱到:kenbest@126.com,收到邮件我们会即时下线处理。
网站框架支持:HDHCMS   51LA统计 百度统计
Copyright © 2018-2025 「好得很程序员自学网」
[ SiteMap ]