Correcting teacher:灭绝师太
Correction status:qualified
Teacher's comments:
<?php
$color1="red";
var_dump($color1);
echo <<<EOF
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>九宫格</title>
</head>
<style type="text/css">
.boxfather {
display: flex;
flex-wrap: wrap;
width: 150px;
}
.box {
width: 50px;
height: 50px;
box-sizing: border-box;
border: 1px solid black;
}
</style>
<body>
<body>
<div class="boxfather">
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
<div class="box" style="background-color:{$color1}"></div>
</div>
</body>
</body>
</html>
EOF;
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>计算器</title>
</head>
<body>
<?php
error_reporting(E_ALL & ~E_NOTICE);
if(isset($_POST['sub']))
{
if($_POST['opt'] == '/' && $_POST['num2'] == 0 || $_POST['opt'] == '%' && $_POST['num2'] == 0) $mess = "<span style='color:red;'>oops~除数不能为0</span>";
}
?>
<table border="1">
<form action="" method="POST">
<tr>
<th colspan="3">计算器</th>
</tr>
<tr>
<td><input type="number" name="num1" required></td>
<td>
<select name="opt">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
</td>
<td><input type="number" name="num2" required></td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" name="sub" value="计算">
</td>
</tr>
</form>
</table>
<?php
if(!$mess):
switch($_POST['opt']):
case "+":
$sum = (int)$_POST['num1'] + (int)$_POST['num2'];break;
case "-":
$sum = (int)$_POST['num1'] - (int)$_POST['num2'];break;
case "*":
$sum = (int)$_POST['num1'] * (int)$_POST['num2'];break;
case "/":
$sum = (int)$_POST['num1'] / (int)$_POST['num2'];break;
case "%":
$sum = (int)$_POST['num1'] % (int)$_POST['num2'];break;
endswitch;
$res = "计算结果:{$_POST['num1']} {$_POST['opt']} {$_POST['num2']} = {$sum}";
echo "<span style='color:green;'>{$res}</span>";
else:
echo $mess;
endif;
?>
</body>
</html>