我的代码中有这个:
fflush(stdout); // right before your scanf line.
但是,即使if($reuqest_id == "736" OR "015" OR "629" OR "260" OR "943" OR "365" OR "331" OR "774" OR "151" OR "452" OR "844" OR "473" OR "850" OR "173" OR "113" OR "067" OR "933" OR "259" OR "617" OR "260" OR "707" OR "256" OR "963" OR "554" OR "344" OR "173" OR "292" OR "478" OR "275") {
die("Restricted");
}
不匹配,它也会一直死亡。我以为是因为它死了,之后无法读取request_id
,但这看起来很奇怪。我查了}
,但这似乎不适用于此。我也试过这个:
OR DIE
但它也没有用。
答案 0 :(得分:3)
问题是每次“或”之后你需要再次进行全面检查:
$request_id === "736" || $request_id === "015" || $request_id === "629"
//and so on...
要避免这种情况,请使用in_array()
。
$listOfIds = ["736", "015", "629", "260", "943", "365", "331", "774", "151", "452", "844", "473", "850", "173", "113", "067", "933", "259", "617", "260", "707", "256", "963", "554", "344", "173", "292", "478", "275"];
if(in_array($request_id, $listOfIds)) {
die("Restricted");
}
答案 1 :(得分:0)
您必须将变量与每个值进行比较,如下所示:
if ($reuqest_id == "736" || $reuqest_id == "015" || $reuqest_id == "629"...) {
另外,请检查:
可能是你拼错了变量名:$reuqest_id
似乎很奇怪,我的猜测必须是$request_id
我们看不到这个值是如何符号的。如果是整数,则某些比较可能导致FALSE:“015”与015不同。