php://The wrapper supports access to various I/O streams. This includes standard input, output, and error streams. In-memory, disk-backed, and filtered streams are also accessible via the php:// protocol.
php://stdin, php://stdout and php://stderr respectively Allows the PHP process direct access to the standard input stream device, standard output stream, and error stream. The predefined constants STDIN, STDOUT, and STDERR represent these streams respectively.
This wrapper represents a write-only stream, Allows buffering mechanisms, similar to print and echo statements.
a file descriptor is accessible through this wrapper. The standard streams STDIN, STDOUT, and STDERR are assigned file descriptors 1, 2, and 3. Every other stream is assigned an incrementing file descriptor. So php://fd/5 refers to file descriptor 5
which is a read/write stream that allows data to be stored temporarily in memory. php://temp Wrapper is similar. However, in the latter case, the data is stored in temporary files instead of in memory.
This wrapper allows a filter to be applied to a stream while the stream is being filtered. Open. Filters are particularly useful for the readfile(), file_get_contents(), and file() functions.
In the following example, console input is read from php://stdin and used php://stdout
Show output<?php $file=fopen("php://stdin","r"); $x=fread($file,10); echo $x; $out=fopen("php://stdout","w"); fwrite($out, $x); fclose($file); ?>
php://input Stream wrapper allows getting raw data from HTTP requests. In the example below, an HTML form uses the POST method to send data to a PHP script
<html> <body> <form action="testscript.php" method="POST"> <input type="text" name="name"> <input type="text" name="age"> <input type ="submit" value="submit"> </form> </body> </html>
The PHP script to retrieve the raw HTTP data is as follows -
<?php $json = file_get_contents("php://input"); $data = json_decode($json); print_r($json); ?>
The above is the detailed content of Translation: PHP php://. For more information, please follow other related articles on the PHP Chinese website!