I am writing an android app to connect to PHP web service and through my searches in internet I faced file_get_contents('php://input');
and I understood some parts of it's functionality but I still don't get it. What are php://input
or php://stdin
or stuff like that?
I've read http://php.net/manual/en/function.file-get-contents.php and I confused much more.
Please explain it completely.
file — Reads entire file contents into an array of lines. file_get_contents — Reads entire file contents into a string.
This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to length bytes. On failure, file_get_contents() will return false . file_get_contents() is the preferred way to read the contents of a file into a string.
Open the file and set the path of the file from where the file will be read. The second argument of the file_get_contents() is required to set true or FILE_USE_INCLUDE_PATH to read the file from the path defined in the include_path parameter.
Short answer: No. file_get_contents is basically just a shortcut for fopen, fread, fclose etc - so I imagine opening a file pointer and freading it isn't cached.
The information comes from here: http://www.php.net/manual/en/wrappers.php.php
When information is sent to the server via a POST
request, it is saved in a temporary file.
The command file_get_contents('php://input')
reads the raw information sent to PHP -- unprocessed before it ever gets put into $_POST
or $_REQUEST
super globals.
This technique is often used when someone is uploading a file, such as an image.
EDIT: removed $_GET
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