PHP input/Output stream learning notes, input and output learning notes
PHP input and output streams are accessed through php://, which allows access to PHP's input and output streams, standard input and output and error descriptors, in-memory, backup-to-disk temporary file streams, and filters that can manipulate other read-write file resources.
Php://stdin, Php://stdout and Php://stderr
Php://stdin,php://stdout and Php://stderr allow access to the appropriate input or output streams of the PHP process.
Php://input
Php://input is a read-only stream of raw data that can access the request. Post request, it is best to use php://input instead of the $HTTP _raw_post_data (native POST data) because it does not rely on specific php.ini instructions and consumes less memory. The following example:
<?php Echo file_get_contents ("Php://input");? >
Results:
Php://output
Php://output is a write-only data stream that allows you to write to the output buffer in the same way as print and echo.
Php://fd
PHP://FD allows direct access to the specified file descriptor. For example, PHP://FD/3 references the file descriptor 3.
Php://memory and Php://temp
Php://memory and php://temp are data streams that are similar to file wrappers that allow temporary data to be read and written. The only difference between the two is that php://memory always stores the data in memory, and php://temp it into a temporary file after the amount of memory reaches a predefined limit (by default, 2MB). The temporary file location is determined in the same way as Sys_get_temp_dir ().
Php://filter
Php://filter is a meta-wrapper designed for filtering and filtering applications when data flow is turned on. This is useful for all-in-one (all-in-one) file functions, such as ReadFile (), file (), and file_get_contents (), without the opportunity to apply other filters before the data stream content is read. The parameters are as follows:
The following example:
<?php/* This will output the entire contents of www.jb51.net in uppercase letters */readfile ("php://filter/read=string.toupper/resource=http://www.bkjia.com ");? >
http://www.bkjia.com/PHPjc/998566.html www.bkjia.com true http://www.bkjia.com/PHPjc/998566.html techarticle PHP input/output stream learning notes, input/output learning notes PHP input and output streams are accessed via php://, which allows access to PHP's input and output streams, standard input and output, and error descriptions ...