문제

I have a page with this code:

<?php
    if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    header('HTTP/1.0 405 Method Not Allowed');
    exit(); }

If I access it with a form in GET method, it works, and doesn't exit, which is ok. But when I try to access this file directly, I would expect the file to perform the exit -
unless, a GET request is sent automatically whenever one access a file, even when not through a form?

도움이 되었습니까?

해결책

unless, a GET request is sent automatically whenever one access a file, even when not through a form?

It is.

When you follow a link or type a URL into the address bar, you are getting a resource (you aren't asking for just metadata (HEAD), or sending any kind of data (PUT, POST), or deleting something (DELETE)) so you use GET.

다른 팁

Unless you specifically issue a POST, PUT, HEAD, etc. request then it is GET. If you click a link in a page or use the URL bar in the browser it is GET.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top