This article to share the content is about PHP input and output stream, the need for friends can refer to
Today, someone phpchina ask me about PHP, how to do XML? , and the corresponding solutions have been given above. By the way, let's talk about PHP's input and output streams.
Today's summer vacation in the company, just when colleagues use flash to create streaming media, you need to use PHP to read Flash passed through the media information (also XML format), at that time I also familiar with the basic PHP input and output stream principle.
The manual says:
PHP 3.0.13 and above, since PHP 4.3.0 support Php://output and php://input, since PHP 5.0.0 Support Php://filter.
Php://stdin
Php://stdout
Php://stderr
Php://output
Php://input
Php://filter
Php://stdin,php://stdout and Php://stderr allow access to the appropriate input or output streams of the PHP process.
The php://output allows data to be written to the output buffering mechanism in the same way as print () and Echo ().
Php://input allows the raw data to be read from the POST. Compared to $HTTP _raw_post_data, it brings less pressure to memory and does not require any special php.ini settings. Php://input cannot be used for 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 a filter program to become a stream when it is opened. This is useful for individual file functions with full functionality such as ReadFile (), files (), and file_get_contents (), otherwise there is no opportunity to apply filters to the stream before reading the content.
That is, the original data of the post is saved in a file called Php://input. You can use the simple file operation to read the data inside to control.
$data =file_get_contents (php://input);