我正在传递GET
参数,如下所示:
test.php?code=10NE25w4hjjh.
如何删除所有其他GET
参数?例如,仅白名单"代码"GET
。
为什么要这样做?忽略其余部分要容易得多。
if (isset($_GET['code'])) {
// do something
}
// all code below here is unnecasary
else {
exit;
}
if ($_GET['code'] != '10NE25w4hjjh' || count($_GET) > 1)
{
header('HTTP/1.0 403 Forbidden');
echo 'Operation killed.';
exit;
}
// Continue
代码必须是10NE25w4hjjh,并且只允许使用GET参数代码。