php://input is a special stream type in PHP that provides access to the body of HTTP requests received by your PHP script. Particularly in POST, PUT, and DELETE requests, request data is carried in the HTTP body. The
php://input stream allows you to read this body data directly.
For instance, if you want to process a JSON body, you can use the
php://input stream as follows:
$json = file_get_contents('php://input');
$data = json_decode($json, true); // the true parameter ensures that the result is an array
This code loads the JSON data in the HTTP request body into a variable, and then converts this data into an array that you can use in your PHP code.
php://input stream is commonly used in some PHP frameworks and custom API processing scenarios.