How should php determine whether it is a get or a post request
What this article shares with you is about how php should judge whether it is a get request or an post request. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
The variable "$_ SERVER" in php can be used to determine whether it is a get or post request, with the syntax "if ($_ SERVER ['REQUEST_METHOD'] =' GET')" or "if ($_ SERVER ['REQUEST_METHOD'] =' POST')".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In practice, GET is used to fetch data, such as what page to jump to, to make some logical judgments.
POST is mostly form submission. It is not recommended to use GET when using forms, unless, as I said above, you have to act to get data. GET is a little easier to understand logically.
PHP, on the other hand, is very simple, unifying GET and POST, and simply putting them into one variable. You no longer have to understand the logic of the whole request. So in php, you seldom think about whether to use post or get.
PHP is the correct way to determine whether the request type is POST or GET
$_ SERVER ['REQUEST_METHOD']
A simple PHP determines whether the request type is POST or GET sample code: