如果与其他许多人一起工作,直到3次尝试,当它达到4时才起作用

时间:2017-09-22 04:15:12

标签: php if-statement

    $oride='';
    $count = "25";
    $origin = $_POST["origin"];
    $destinataion = $_POST["destination"];
    $oride = ($destination = $_POST["destination"] - 
    $origin= $_POST["origin"]);

    if ($oride <="0"){
        echo "invalid";
    }
    elseif ($oride <="15"){
        echo $count;
    }
    elseif ($oride ="16"){
        echo $count + "1";
    }
    elseif ($oride ="17"){
        echo $count + "2";
    }

如果声明正常,直到$ oride =&#34; 16&#34;但当它达到$ oride =&#34; 17&#34;它仍然选择26它应该是27

1 个答案:

答案 0 :(得分:2)

=是赋值运算符。您需要=====(如果数据类型也需要相等)进行比较

$oride='';
$count = "25";
$origin = $_POST["origin"];
$destinataion = $_POST["destination"];
$oride = ($destination = $_POST["destination"] - 
$origin= $_POST["origin"]);

if ($oride <="0"){
    echo "invalid";
}
elseif ($oride <="15"){
    echo $count;
}
elseif ($oride =="16"){
    echo $count + "1";
}
elseif ($oride =="17"){
    echo $count + "2";
}