What is the relevance of php://input
in the following snippet, and what is it used for?
$json_string = GPTake(array('json_string'));
$handle = fopen('php://input', 'r');
$jsonInput = fgets($handle);
$test = json_decode($jsonInput);
php://input php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives.
Try it Yourself ». When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php". The form data is sent with the HTTP POST method. To display the submitted data you could simply echo all the variables.
php://input. php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives.
When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php". The form data is sent with the HTTP POST method.
It gives you direct access to the input stream, as opposed to accessing the data after PHP has already applied the $_GET
/$_POST
super globals. Also, according to the manual, it is both less intensive and allows you to grab information before any php.ini directives have been applied.
For more information, read the PHP Manual on php://input
php://
is a scheme wrapper around various input/output streams that PHP supports. You can read up for here: http://www.php.net/manual/en/wrappers.php.php.
Specifically, php://input
allows you to read the input stream directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With