日期:2014-05-17  浏览次数:20547 次

关于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"];
为什么变量前面加@有什么特别效果吗?
------解决方案--------------------
不明白楼主为什么要加那么多错误控制符,如果不报出错误,你怎么修改代码呢?
将楼主的代码修改了下:
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 &amp;&amp; $keyboard>0){
@$keyboardfinal=50;
}
}
if(@$judge==2){
if(@$keyb……