Heim > Fragen und Antworten > Hauptteil
<form action="abc.php" method="post">
<input type="text" name="nianfen"/>
<input type="submit" name= "Senden"/>
</form>
<?php
$n = $_POST['nianfen'];
if($n<0| |!is_numeric($n)){
echo 'Bitte geben Sie das richtige Jahr ein';
exit
}
if($n.'%'.'400'==0){
echo 'Leap Year';
Exit;
}
if($n.'%'.'4'==0&&(!($n.'%'.'100 ' ==0))){
echo 'Leap Year';
Exit;
}
else{
Echo 'normales Jahr';
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 . "是平年";
}
}
?>