第一个有平等的人会工作,我希望如此。但第二个没有按预期工作。
$nicktest = "new";
if ($nicktest == "new" || $nicktest == "fun" || $nicktest == "norm" || $nicktest == "pvp")
{
$odpoved = "Ok it works.";
echo $odpoved;
return;
}
$nicktest = "new";
if ($nicktest != "new" || $nicktest != "fun" || $nicktest != "norm" || $nicktest != "pvp")
{
$odpoved = "Ok it works too why?";
echo $odpoved;
return;
}
答案 0 :(得分:0)
您的4个条件得到以下评估:
false,true,true,true
现在,
if (false || true || true || true) {
// Code block is actually evaluated
}
如果你碰巧有:
if (false || false || false || false) {
// Code block wouldn't be evaluated
}
根据此方案,至少有一个true
条件可以获得要评估的代码