为了账号安全,请及时绑定邮箱和手机立即绑定

送积分啦,PHP判断单科成绩的小code,出错了,小白白不知道哪里的问题,呜呜呜,谁来帮帮我?呜呜呜

送积分啦,PHP判断单科成绩的小code,出错了,小白白不知道哪里的问题,呜呜呜,谁来帮帮我?呜呜呜

侠客岛的含笑 2016-10-25 20:13:49
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <title>无标题文档</title>     <style type="text/css">         body{             font-size:18px;         }     </style> </head> <body>         <?php             $str='';         if(isset($_GET['1name'])) {             $name = $_GET['1name'];             if (!empty($name)) {                 if (!is_numeric($name)) {                     if (isset($_GET['lscore'])) {                         $score = $_GET['lscore'];                         if (!empty($score)) {                             if (is_numeric($score)) {                                 if ($score >= 0 && $score <= 100) {                                     switch ((integer)($score / 10))//0,1,2,3,...,10                                     {                                         case 10:                                             $str = 'A+';                                             break;                                         case 9:                                             $str = 'A';                                             break;                                         case 8:                                             $str = 'B';                                             break;                                         case 7:                                             $str = 'C';                                             break;                                         case 6:                                             $str = 'D';                                             break;                                         default:                                             $str = 'fail';                                             break;                                     }                                 } else {                                     $str = "成绩过高,抄书十遍!";}                             } else {                                 $str = "成绩是数学?Are you a fool?";}                         } else {                             $str = "成绩不能为空!";}                     }                 } else {                     $str = "姓名不能为数字!";}             } else {                 $str = "姓名不能为空!";}         }         ?> <form action="#" method="get">     请输入学生的姓名:     <input type="text"  name="lname" value="<?php if(!empty($_POST["lname"])){ echo $_GET["lname"] ;} ?>" /><br />     请输入学生的成绩:     <input type="text"  name="lscore" value="<?php if(!empty($_POST["lscore"])){echo $_GET["lscore"];} ?>" /><br />     <input type="submit" value="提交" /> </form>         <?php         echo $str;         ?> </body> </html>
查看完整描述

3 回答

?
echo1111

TA贡献21条经验 获得超6个赞

function xxxXX($params1,$params2)
{
    if(!isset($_GET['name'])) {
        return '请输入你的姓名';
    }
    if(!isset($_GET['score'])) {
        return '请输入你的姓名';
    }
    .....
}

我觉得你这样写好一点,代码可读性更强

查看完整回答
反对 回复 2016-10-26
  • 3 回答
  • 0 关注
  • 1686 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信