亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

送積分啦,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 關注
  • 1734 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號