關於php擷取變數有關問題

來源:互聯網
上載者:User
關於php擷取變數問題
PHP code
@$judge=$_GET["speed"];if(@$keyboard=$_GET["keyboard"]){$keyboardfinal=100;}if(@$judge==1){if($keyboard<40 && $keyboard>0){@$keyboardfinal=50;    }}if(@$judge==2){if(@$keyboard<50&& $keyboard>0){$keyboardfinal=50;    }}if(@$judge==3 && (@$keyboard<170 && @$keyboard>0)){$keyboardfinal=50;    }

如上代碼~為什麼在第二,三,四個if語句中,即使條件成立任然無法使$keyboardfinal=50;成立為什麼呢?


------解決方案--------------------
@$judge=$_GET["speed"];
[email protected]?
------解決方案--------------------
不明白樓主為什麼要加那麼多錯誤控制符,如果不報出錯誤,你怎麼修改代碼呢?
將樓主的代碼修改了下:
PHP code
$judge = 1;$keyboard = 35;$keyboardfinal = null;switch($judge){    case 1:        if($keyboard<40 && $keyboard>0)            $keyboardfinal=50;        break;    case 2:        if($keyboard<50&& $keyboard>0)            $keyboardfinal=50;        break;    case 3 && ($keyboard<170 && $keyboard>0):        $keyboardfinal=50;        break;}echo "keyboardfinal-->>".$keyboardfinal;#50
------解決方案--------------------
探討
PHP code
@$judge=$_GET["speed"];
if(@$keyboard=$_GET["keyboard"]){
$keyboardfinal=100;
}
if(@$judge==1){
if($keyboard<40 && $keyboard>0){
@$keyboardfinal=50;
}
}
if(@$judge==2){
if(@$keyb……
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.