<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <meta charset="utf-8" /> </head> <body> <h1>请输入五个成绩,用空格隔开</h1> <form action="11result.php" method="post"> <input type="text" name="grade"> <input type="submit" value="开始统计"> </form> </body> </html>
//表单提交的代码
<?php //接收用户提交的学生的成绩 $grade=$_REQUEST["grade"]; // echo $grade; //拆分请求的数据 $grade=explode(" ",$grade); $allGrades=0; //遍历 foreach($grade as $k=>$val) { $allGrades+=$val; } echo "平均值=".$allGrades/count($grade); ?>
时间: 2024-10-26 04:29:34