Home>Article>Backend Development> Explain PHP’s input and output streams
The content of this article is about the input and output streams of PHP. Friends in need can refer to it
Today someone asked me on PHPCHINA how to transfer XML from PHP? , and the corresponding solutions have been given above. By the way, let’s talk about PHP’s input and output streams.
When I was at the company during the summer vacation, my colleagues happened to be using Flash to create streaming media. They needed to use PHP to read the media information (also in XML format) passed by FLASH. At that time, I was also familiar with the basics of PHP. Input and output flow principles.
The manual says:
PHP 3.0.13 and above, starting from PHP 4.3.0, support php://output and php://input, starting from PHP 5.0. php://filter is supported starting from 0.
php://stdin
php://stdout
php://stderr
php://output
php://input
php://filter
php://stdin, php://stdout and php://stderr allow access to the corresponding input of the PHP process or output stream.
php://output allows writing data to the output buffering mechanism in the same way as print() and echo().
php://input allows reading the raw data of POST. It puts less pressure on memory than $HTTP_RAW_POST_DATA and does not require any special php.ini settings. php://input cannot be used with enctype="multipart/form-data".
php://stdin and php://input are read-only, while php://stdout, php://stderr and php://output are write-only.
php://filter is a wrapper protocol designed to allow filter programs to become streams when opened. This is useful for file functions such as readfile(), file() and file_get_contents() that have full functionality on their own, as otherwise there would be no opportunity to apply filters on top of the stream before reading the contents.
# In other words, the original data of the post is saved in a file called php://input. You can control it by reading the data inside through simple file operations.
$data=file_get_contents(php://input);
Related recommendations:
Detailed sample code for php input and output streams (picture)
##
The above is the detailed content of Explain PHP’s input and output streams. For more information, please follow other related articles on the PHP Chinese website!