Home  >  Q&A  >  body text

Why not run the code for leap years?

<form action="abc.php" method="post">

<input type="text" name="nianfen"/>

<input type="submit" name="Submit"/>

</form>

< ;?php


$n = $_POST['nianfen'];

if($n<0||! is_numeric($n)){

echo 'Please enter the correct year';

exit;

}

if($n.'%'.'400'==0){

echo 'leap year';

exit;

}

if($n.'%'.'4'==0&&(!($n.'%'.'100' ==0))){

echo 'leap year';

exit;

}

else{

echo '平年';

exit;

}














#?>

phpcn_u54510phpcn_u545102561 days ago1320

reply all(1)I'll reply

  • 卿立平

    卿立平2018-01-14 19:56:41

    <?php

    $year = $_GET['year'];

    //Determine whether the entered year is a numerical value

    if(!is_numeric($year)){

    echo 'Please enter the numeric type';

    }

    //If it is a numeric value, Just determine whether it is a leap year or a normal year

    if($year%100==0){

    if($year%400==0 && $year%3200!=0){

    echo "century year" . $year . "is a leap year";

    }else{

    echo "century year" . $year . "is a normal year" ;

    }

    }else{

    if($year%4==0 && $year%100!=0){

    echo "Ordinary year" . $year . "It is a leap year";

    }else{

    echo "It is an ordinary year" .$year . "It is an ordinary year";

    }

    }

    ?>


    reply
    0
  • Cancelreply