闰年平年判断

闰年平年判断1
1
2
3
4
5
6
7
8
9
10
11
12
<?php

header("Content-Type: text/html;charset=utf-8"); //语言强制

$yeaar = 2023;
//$yeaar = 2020;

$expression = ($yeaar % 4 == 0 && $yeaar %100 != 0)|| ($yeaar % 400 == 0) ? "闰年": "平年";

echo $yeaar ."年是".$expression;

?>
闰年平年判断2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Year</title>
</head>
<body>
<form action="" method="post">
请输入年份:<input type="text" value="" name="year">
<input type="submit" value="计算结果"><br /> <!--按钮-->
</form>
</body>
</html>
<?php
if(isset($_POST['year']) )
{
$year = $_POST['year']; //年份
echo "<br>";
if( is_numeric($year))
{


if( $year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0) //能否被整除
{
echo $year."是闰年"; //输出闰年
}
else
{
echo $year."不是闰年";
}
}
else //输入其他
{
echo "你没有正确输入年份!";
}

}
?>

座位号输出

座位号输出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

header("Content-Type: text/html;charset=utf-8"); //语言强制

$maxline = 4;

$no = 17;

$line = ceil($no/$maxline);

$row = $no%$maxline?$no%$maxline:$maxline;

echo "编号<b>".$no."</b>的座位在第<b>".$line."</b>排第<b>".$row."</b>个位置";

?>