Home > Backend Development > PHP Tutorial > Talk about PHP's input and output streams_PHP tutorial

Talk about PHP's input and output streams_PHP tutorial

WBOY
Release: 2016-07-21 15:56:54
Original
1058 people have browsed 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 supports php://output and php://input since PHP 4.3.0, and supports php://filter since PHP 5.0.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 or output streams of the PHP process.​

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);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317930.htmlTechArticleToday 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. Today when I was at the company during the summer vacation, I happened to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template