Question: We
have to ask user to enter year he/she wants, and give output whether its leap year or not?
Answer: Copy the below code and paste it into "your.php" file. After done this you will just need to run "your.php" file in browser and you will get the output successfully.
Answer: Copy the below code and paste it into "your.php" file. After done this you will just need to run "your.php" file in browser and you will get the output successfully.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>leap year</title> </head> <body> <h1><center>leap year</center></h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Enter the year in four digit: <input type="text" name="year" /> <input type="submit" name="submit" value="OK" /> </form> <?php if (isset($_POST['submit'])) { $yr = $_POST['year']; if ($yr % 4 == 0) { if ($yr % 100 == 0) { if ($yr % 400 == 0) { echo $yr . " is leap year"; } else echo $yr . " is not leap year"; } else echo $yr . " is leap year"; } else echo $yr . " is not leap year"; } ?> </body> </html>
No comments:
Post a Comment