Talk about PHP input and output flow _php technique

Source: Internet
Author: User
Tags stdin
Today, someone asked me again Phpchina how to do PHP XML? , and the corresponding solution has been given. By the way, talk about the input and output stream of PHP.

Today summer vacation in the company, just colleagues use flash to create streaming media, need to use PHP to read the Flash pass over the media information (also XML format), at that time I was also familiar with the basic input and output flow of PHP.

The handbook says:


PHP 3.0.13 and above version, from PHP 4.3.0 support Php://output and Php://input, from 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 corresponding input or output stream of the PHP process.

Php://output allows you to write data to the output buffering mechanism, and print () is the same way as Echo ().

Php://input allows you to read the original data for the POST. Compared with $HTTP _raw_post_data, it brings less pressure on 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 written only.

Php://filter is a package protocol designed to allow a filter program to become a stream when it is opened. This is useful for individually full-featured file functions such as ReadFile (), file (), and file_get_contents (), otherwise there is no chance of applying the filter to the stream before the content is read.





This means that the original data for the post is stored 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.