zoukankan      html  css  js  c++  java
  • php之实战项目--年份判断是否为闰年

    实现效果:

    实现代码:

    <html>
    <head>
    <meta charset="utf8">
    </head>
    <body>
    <table border="1" align="center" width="450" height="101" cellpadding="1" cellspacing="1" bgcolor="#ccff00">
    <tr><td height="25" align="center" colspan="2">判断指定的年份是否为闰年</td></tr>
    <tr bgcolor="#ffff99">
    <td width="200" height="30" >请输入一个四位数的年份:</td>
    <td >
    <form action="" method="post">
    <input type="text" name="year">
    <input type="submit" name="submit" value="计算">
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <?php
    if(isset($_POST['submit'])){
    if($_POST['year']=="") echo "请输入年份后再提交!";
    else{
    $year=$_POST['year'];
    $result=($year%4==0&&$year%100!=0)||($year%400==0)?$year."是闰年":$year."不是闰年";
    echo $result;
    }
    }
    ?>
    </td>
    </tr>
    </table>
    </body>
    </html>

  • 相关阅读:
    最长有效括号
    C++ 环形缓存区的实现
    vector的原理与底层实现
    聚合分析与分组
    求两个数的最大公约数
    单例模式
    工厂方法模式
    责任链模式
    适配器模式
    策略模式
  • 原文地址:https://www.cnblogs.com/xy95/p/5824322.html
Copyright © 2011-2022 走看看