发送方法不允许标题以及一些解释性文本(最好是比我下面的例子更友好和更有用的东西).
之后退出,因此您无法继续使用常规页面进行处理.
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
header('Method Not Allowed', true, 405);
echo "GET method requests are not accepted for this resource";
exit;
}
Run Code Online (Sandbox Code Playgroud)
你可能想要考虑白名单(并测试你没有接受的方法),而不是黑名单GET.(因为你可能不想要PUT,DELETE等).