首页 > Web开发 > 详细

php之实战项目--年份判断是否为闰年

时间:2016-08-31 02:13:01      阅读:302      评论:0      收藏:0      [点我收藏+]

实现效果:

技术分享

实现代码:

<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>

php之实战项目--年份判断是否为闰年

原文:http://www.cnblogs.com/xy95/p/5824322.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!