<form action="abc.php" method="post">
<input type="text" name="nianfen"/>
<input type="submit" name="提交"/>
</form>
<?php
$n = $_POST['nianfen'];
if($n<0||!is_numeric($n)){
echo '请输入正确的年份';
exit;
}
if($n.'%'.'400'==0){
echo '闰年';
exit;
}
if($n.'%'.'4'==0&&(!($n.'%'.'100'==0))){
echo '闰年';
exit;
}
else{
echo '平年';
exit;
}
?>
卿立平2018-01-14 19:56:41
<?php
$year = $_GET['year'];
//判断输入的年份是否是数值
if(!is_numeric($year)){
echo '请输入数值类型';
}
//如果是数值,就判断是否是闰年或者平年
if($year%100==0){
if($year%400==0 && $year%3200!=0){
echo "世纪年" . $year . "是闰年";
}else{
echo "世纪年" . $year . "是平年" ;
}
}else{
if($year%4==0 && $year%100!=0){
echo "普通年" . $year . "是闰年";
}else{
echo "普通年" .$year . "是平年";
}
}
?>