You want to read from standard input in a command-line context—for example, to get user input from the keyboard or data piped to your PHP program.
Use fopen() to open php://stdin:
1 2 3 4 |
$fh = fopen('php://stdin','r') or die($php_errormsg); while($s = fgets($fh)) { print "You typed: $s"; } |
Reading data from standard input isn’t very useful in a web context, because information doesn’t arrive via standard input.
The bodies of HTTP POST and fileupload requests are parsed by PHP and put into special variables.
Non–file-upload POST request bodies can also be read with the php://input stream.