示例#1
0
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tim_nam_nhuan</title>
</head>

<body>
<?php 
if (isset($_POST["nam"])) {
    $nam = $_POST["nam"];
    function nam_nhuan($nam)
    {
        return $nam % 400 == 0 || $nam % 4 == 0 && $nam % 100 != 0;
    }
    $tb = "";
    foreach (range(2000, $nam) as $year) {
        if (nam_nhuan($year)) {
            $tb = $tb . $year . " ";
        }
    }
    if ($tb != "") {
        $tb = $tb . "là năm nhuận";
    } else {
        $tb = "Không có năm nhuận";
    }
}
?>
<form action="tim_nam_nhuan.php" method="post" accept-charset="utf-8">
<table width="500" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFCC">
 <tr>
     <td colspan="2" align="center" bgcolor="#dd4800"><strong>TÌM NĂM NHUẬN</strong></td>
 </tr>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tinh_ngay_trong_thang_nam_nhuan</title>
</head>

<body>
<?php 
if (isset($_POST["t"]) && isset($_POST["nam"])) {
    $t = $_POST["t"];
    $nam = $_POST["nam"];
    function nam_nhuan($nam)
    {
        return $t == 2 && $nam % 400 == 0 || $nam % 4 == 0 && $nam % 100 != 0;
    }
    if (nam_nhuan($nam)) {
        $nam_nhuan = "Năm {$nam} là năm nhuận và ";
    }
    $d = cal_days_in_month(CAL_GREGORIAN, $t, $nam);
    $kq = $nam_nhuan . "Tháng {$t} năm {$nam} có: {$d} ngày";
}
?>
<form action="tinh_ngay_trong_thang_nam_nhuan.php" method="post" accept-charset="utf-8">
<table width="500" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFCC">
 <tr>
     <td colspan="2" align="center" bgcolor="#dd4800"><strong>TÍNH NGÀY TRONG THÁNG</strong></td>
 </tr>
 <tr>
    <td width="360" align="center"><span class="style4"><strong>Tháng/năm:</strong> 
      <input name="t" type="text" value="<?php 
echo $_POST["t"];