当前位置: 首页 > news >正文

南昌网站建设行情大学学风建设网站

南昌网站建设行情,大学学风建设网站,手机制作报价单app,域名注册教程php中文网最新课程每日17点准时技术干货分享PHP包含了以php://开头的一系列输出输出流#xff0c;如php://stdin, php://stdout等。今天查看代码时#xff0c;忽然想到一个问题#xff1a;php://output和php://stdout有什么区别#xff1f;从PHP的官方文献中找答案#xf… php中文网最新课程每日17点准时技术干货分享PHP包含了以php://开头的一系列输出输出流如php://stdin, php://stdout等。今天查看代码时忽然想到一个问题php://output和php://stdout有什么区别从PHP的官方文献中找答案对输入流php://stdin和php://input的解释分别如下(输出流的解释过于简略)php://stdinphp://stdin, php://stdout and php://stderr allow direct access to the corresponding input or output stream of the PHP process. The stream references a duplicate file descriptor, so if you open php://stdin and later close it, you close only your copy of the descriptor-the actual stream referenced by STDIN is unaffected. Note that PHP exhibited buggy behavior in this regard until PHP 5.2.1. It is recommended that you simply use the constants STDIN, STDOUT and STDERR instead of manually opening streams using these wrappers.php://stdin is read-only, whereas php://stdout and php://stderr are write-only.php://inputphp://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Moreover, for those cases where $HTTP_RAW_POST_DATA is not populated by default, it is a potentially less memory intensive alternative to activating always_populate_raw_post_data. php://input is not available with enctypemultipart/form-data.文档并未直接阐述两者的区别仔细对比可得出以下信息1. 均是只读流2. php://stdin是PHP进程的标准输入php://input用来读取请求正文的原始数据。通过这些信息该如何正确认识两者的本质区别顺着php://stdin进程输入的提示联想PHP进程的执行过程再结合SAPI的差异可以得到两者主要区别php://stdin是PHP进程的输入流执行生命周期内均可能有数据流入(例如CLI下的交互式输入)php://input是PHP执行时的外部输入流一般数据只能读一次(具体看SAPI的实现)。同理可得到php://stdout和php://output的区别php://stdout是PHP进程的标准输出流php://output是返回的结果数据流。下面用代码验证结论// file: test.phpfile_put_contents(php://output, message sent by output . PHP_EOL);file_put_contents(php://stdout, message sent by stdout . PHP_EOL);print(message sent by print . PHP_EOL);echo SAPI: , PHP_SAPI , PHP_EOL;命令行执行文件输出如下message sent by outputmessage sent by stdoutmessage sent by printSAPI:cli浏览器端请求输出如下message sent by outputmessage sent by printSAPI:fpm-fcgi在命令行下PHP进程的标准输出流和结果输出流均指向终端所有消息都打印出来。在浏览器端PHP进程的输出流被忽略只有结果数据流被发送到web服务器。同时print和echo调用的信息都作为执行结果发往结果输出流所以都正常显示。最后再感慨一下PHP内置函数的简洁实用一个file_put_contents函数就搞定流写入操作换Java需要stream/writer一堆代码也省去C风格的fopen/fwrite/fclose的繁琐。-END-声明本文选自「 php中文网 」搜索「 phpcnnew 」即可关注▼
http://www.pierceye.com/news/288745/

相关文章:

  • 张店学校网站建设公司合肥有哪些seo网络公司
  • 做博客网站的空间容量需要多少北京简盟产品设计有限公司
  • 哪些网站怎么进定制开发平台
  • 【郑州网站建设】wordpress自定义后台单页模板
  • 铭誉摄影网站北京网站建设开发
  • 单位还能建设网站吗做网站的程序员留备份
  • 松江团购做网站产品开发的基本流程
  • 织梦后台网站栏目空白小广告制作
  • 钦州建设局网站云南网站建设招商
  • 韩国风格网站php源码网站怎么放到服务器上
  • 网站调优yandex搜索引擎入口
  • 医院网站建设具体内容商丘网站制作电话
  • 别人做的网站直播网站
  • 足球梦网站建设的基本思路沧州做企业网站
  • 招标建设网站什么是微信wordpress
  • 建设银行网站连不上成都网站快照优化公司
  • 网站 永久关停 请示广州网站建设骏域网站
  • 个人建站模板外国网站翻墙怎么做
  • 保定网站设计制作公司有经验的中山网站建设
  • 免费网站建设那个好wordpress本地怎么上传服务器
  • 自己做的网站加载慢WordPress模板首页文件是啥
  • 教学网站建设网站建设岗位有哪些
  • 网站建设合同的验收表网页网站的区别是什么
  • 开福区网站建设中wordpress调用所有栏目
  • 网站建设的流程是什么意思青岛做网站公司
  • 什么网站有项目做中铁建设企业门户网
  • 网站域名商代理商安卓商店
  • 深圳中英文网站建设广州知名设计公司排名
  • 一个公司设计网站怎么做的蜜桃传奇免费网页版
  • 网络推广网站培训班有人用wordpress默认主题