"Missing required parameters: student_id, english, math, computer" ]); exit; } // 验证分数是否为数字 if (!is_numeric($english) || !is_numeric($math) || !is_numeric($computer)) { // 返回错误信息 echo json_encode([ "error" => "Parameters english, math, and computer must be numeric" ]); exit; } // 计算总分 $sum = $english + $math + $computer; // 封装为 JSON 格式 $response = [ "student_id" => $student_id, "sum" => (string)$sum // 转为字符串以匹配返回格式 ]; // 输出 JSON header('Content-Type: application/json'); echo json_encode($response); ?>