Heim  >  Artikel  >  Backend-Entwicklung  >  谈谈PHP的输入输出流_PHP教程

谈谈PHP的输入输出流_PHP教程

WBOY
WBOYOriginal
2016-07-21 15:56:54999Durchsuche

今天有人再PHPCHINA上问我关于PHP传XML怎么做?,再上面已经给出了相应的解决方法。顺便谈谈PHP的输入输出流。

   今天暑假在公司的时候,恰好同事使用flash打造流媒体的时候,需要使用PHP读取FLASH传递过来的媒体信息(也是XML格式),在那个时候我也熟悉了PHP的基本输入输出流原理。

   手册上说:


PHP 3.0.13 及以上版本,自 PHP 4.3.0 起支持 php://output 和 php://input,自 PHP 5.0.0 起支持 php://filter。 


php://stdin

php://stdout

php://stderr

php://output

php://input

php://filter

php://stdin,php://stdout 和 php://stderr 允许访问 PHP 进程相应的输入或者输出流。 

php://output 允许向输出缓冲机制写入数据,和 print() 与 echo() 的方式相同。 

php://input 允许读取 POST 的原始数据。和 $HTTP_RAW_POST_DATA 比起来,它给内存带来的压力较小,并且不需要任何特殊的 php.ini 设置。php://input 不能用于 enctype="multipart/form-data"。 

php://stdin 和 php://input 是只读的,同时 php://stdout,php://stderr 和 php://output 是只写的。 

php://filter 是一种设计用来允许过滤器程序在打开时成为流的封装协议。这对于单独具有完整功能的文件函数例如 readfile(),file() 和 file_get_contents() 很有用,否则就没有机会在读取内容之前将过滤器应用于流之上。 





   也就是说post的原始数据是保存在一个叫php://input的文件。你可以通过简单的文件操作读取里面的数据来控制。

$data=file_get_contents(’php://input’); 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/317930.htmlTechArticle今天有人再PHPCHINA上问我关于PHP传XML怎么做?,再上面已经给出了相应的解决方法。顺便谈谈PHP的输入输出流。 今天暑假在公司的时候,恰...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn