As title.
Also, I just use file_get_contents(php://input) to get them.
Also, I am just confused about how to use $_POST and $_GET in php, even after long time of learning in web!
As I know, they are array, but in many examples, I see people put in the key like
$_POST['key']
But what defines the key and its corresponding value?
Now I am not getting html form from client, but the examples in internet mainly deal with that.
Hope someone can get my questions, and show some examples and solution to me , thanks!
There’s
$_SERVER['REQUEST_METHOD'], which when run in SAPI mode will ALWAYS contain the method of the HTTP request: GET, POST, DELETE, HEAD, etc…. Using this $_SERVER var is 100% reliable. Checking for the presence/absence of form fields is unreliable, especially if you’re modifying the form – one typo on either side and your code fails because what’s being looked for doesn’t exist anymore.