$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
答案 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";
}