What is the difference between file_get_contents ('php://input') and $_ REQUEST in PHP?

what is the difference between the following two ways to obtain data?

file_get_contents("php://input")
$_REQUEST
Php
Jun.29,2021

$_ REQUEST contains $_ POST and $_ GET and $_ COOKIE , which are parsed according to key-value pairs. While php://input is raw data and is unparsed.

if you submit a form form , enctype is application/x-www-form-urlencoded or multipart/form-data , then the key-value pairs in the form will be parsed into the above three hyperglobal variables. And multipart/form-data encoded submitted files are parsed into $_ FILES .

and if the data you submit is not encoded by the above form and may not be parsed, you can use php://input to get the original data submitted.

Menu