Explaining the input and output stream of PHP

Source: Internet
Author: User
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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.