>  기사  >  백엔드 개발  >  关于php获取变量有关问题

关于php获取变量有关问题

WBOY
WBOY원래의
2016-06-13 13:27:04914검색

关于php获取变量问题

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->@$judge=$_GET["speed"];
if(@$keyboard=$_GET["keyboard"]){
$keyboardfinal=100;
}
if(@$judge==1){
if($keyboard0){
@$keyboardfinal=50;
    }
}
if(@$judge==2){
if(@$keyboard0){
$keyboardfinal=50;
    }
}
if(@$judge==3 && (@$keyboard0)){
$keyboardfinal=50;
    }

如上代码~为什么在第二,三,四个if语句中,即使条件成立任然无法使$keyboardfinal=50;成立为什么呢?


------解决方案--------------------
@$judge=$_GET["speed"];
为什么变量前面加@有什么特别效果吗?
------解决方案--------------------
不明白楼主为什么要加那么多错误控制符,如果不报出错误,你怎么修改代码呢?
将楼主的代码修改了下:
PHP code

$judge = 1;
$keyboard = 35;
$keyboardfinal = null;
switch($judge){
    case 1:
        if($keyboard0)
            $keyboardfinal=50;
        break;
    case 2:
        if($keyboard0)
            $keyboardfinal=50;
        break;
    case 3 && ($keyboard0):
        $keyboardfinal=50;
        break;
}
echo "keyboardfinal-->>".$keyboardfinal;
#50
<br><font color="#e78608">------解决方案--------------------</font><br>
探讨
PHP code
@$judge=$_GET["speed"];
if(@$keyboard=$_GET["keyboard"]){
$keyboardfinal=100;
}
if(@$judge==1){
if($keyboard0){
@$keyboardfinal=50;
}
}
if(@$judge==2){
if(@$keyb……
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.