Test1.php
<html>
<head>
</head>
<body>
<h1>请输入学生的成绩,并用空格隔开:</h1>
<form action="result1.php" method="post">
<input type="text" name="grade"/>
<input type="submit" value="开始统计"/>
</form>
</body>
</html>
result1.php
<?php
$grades=$_REQUEST['grade'];
//接收用户提交的成绩
$grades=explode(" ",$grades);
//按照空格将其拆分
$allGrades=0;
foreach($grades as $k=>$v){
$allGrades+=$v;
}
echo "平均成绩是:".$allGrades/count($grades);
?>