注意一下第22行的加法就好了。
有不懂的,评论提出,我在能力范围内回答。
<html>
<head>
<title>算数表</title>
</head>
<body>
<?php
function a($a)
{
echo'<table border="1">';
for($i=9;$i>0;$i--)
{
echo'<tr>';
for($j=$i;$j>0;$j--)
{
echo'<td>';
if($a=="*")
{
echo $i."x".$j."=".$i*$j;
}
else if($a=="+")
{
echo $i."+".$j."=".($i+$j);//字符串的加法和变量的加法要用括号区别开
}
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
}
if(isset($_GET["sub"]))
{
a($_GET["ra1"]);
}
?>
<form method="get" name="form1">
<input type="radio" name="ra1" value="+">加法
<br>
<input type="radio" name="ra1" value="*">乘法
<br>
<input type="submit" name="sub">提交
</form>
</body>
</html>