仅将一个 GET 参数列入白名单

Whitelist only one GET Parameter

我正在像这样传递 GET 参数:

test.php?code=10NE25w4hjjh. 

如何取消所有其他 GET 参数?例如仅限白名单 'code' GET.

if ($_GET['code'] != '10NE25w4hjjh' || count($_GET) > 1)
{
   header('HTTP/1.0 403 Forbidden');

   echo 'Operation killed.';
   exit;
}

// Continue

code必须是10NE25w4hjjh,只允许GET参数code。

你为什么要这样做?忽略其余部分要容易得多。

if (isset($_GET['code'])) {
    // do something
}
// all code below here is unnecasary 
 else {
   exit; 
}