$HTTP_RAW_POST_DATA

 

The RAW / uninterpreted HTTP POst information can be accessed with:
   $GLOBALS['HTTP_RAW_POST_DATA']
This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).

也就是说,基本上$GLOBALS['HTTP_RAW_POST_DATA'] 和 $_POST是一样的。但是如果post过来的数据不是PHP能够识别的,你可以用 $GLOBALS['HTTP_RAW_POST_DATA']来接收,比如 text/xml 或者 soap 等等。

PHP默认识别的数据类型是application/x-www.form-urlencoded标准的数据类型

用Content-Type=text/xml 类型,提交一个xml文档内容给了php server,要怎么获得这个POST数据。

The RAW / uninterpreted HTTP POST information can be accessed with:   $GLOBALS['HTTP_RAW_POST_DATA'] This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).

由于PHP默认只识别application/x-www.form-urlencoded标准的数据类型,因此,对型如text/xml的内容无法解析为$_POST数组,故保留原型,交给$GLOBALS['HTTP_RAW_POST_DATA'] 来接收。

另外还有一项 php://input 也可以实现此这个功能

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

应用

a.htm   
  ------------------   
  <form   action="post.php"   method="post">   
      <input   type="text"   name="user">   
      <input   type="password"   name="password">   
      <input   type="submit">   
  </form>      
    
  post.php   
  ----------------------------   
  <?   echo   file_get_contents("php://input");   ?>   

转载保留链接

随机推荐

  1. Exception inside CORBA when accessing a remote bean

    http://stackoverflow.com/questions/23291520/exception-inside-corba-when-accessing-a-remote-bean

  2. 洛谷 P1908 逆序对(归并排序解法)

    树状数组解法:https://www.cnblogs.com/lipeiyi520/p/10846927.html 题目描述 猫猫TOM和小老鼠JERRY最近又较量上了,但是毕竟都是成年人,他们已经不 ...

  3. 分享| 语义SLAM的未来与思考(泡泡机器人)

    相比典型的点云地图,语义地图能够很好的表示出机器人到的地方是什么,机器人“看”到的东西是什么.比如进入到一个房间,点云地图中,机器人并不能识别显示出来的一块块的点云到底是什么,但是语义地图的构建可以分 ...

  4. [Android]Android四大组件之ContentProvider

    URI简介 URI(Universal Resource Identifier),又被称为"通用资源标志符". URI由许多部分所组成,示例及解说如下: Content URIs介 ...

  5. hdu6070Dirt Ratio 多校题 套路二分

    比赛中我看了一眼题目就觉得是二分的套路,跟miaom说,结果发现miaom开始碎觉 miaom醒来以后表示这是道凸包合并(%%%) 我&wzf2000:那您快写啊 miaom:我不会写啊 莫名 ...

  6. vconsole移动端调试技巧(禁止webviuew,inspect等)

    如果由于某种原因(天朝FQ),不能支持google 的 inspect  调试 或者再想在某个APP里面调试你的页面,但是没有打开APP的webview ,也不能授权调试 在或者,Fider 可以拦截 ...

  7. vue2.0:(五)、路由vue-router

    好的,接下来,我们来写路由.用的是vue2.0的路由. 步骤一:配置main.js import Vue from 'vue'; import App from './App'; import rou ...

  8. 解决easyUI下拉控件无法触发onkeydown事件

    实现在combotree下拉控件中按Backspace键清除combotree选中的值 下面的代码无法获取到键盘事件 <input class="easyui-combotree&qu ...

  9. redis 大批量数据插入导致MISCONF Redis is configured to save RDB snapshots的解决

    PS:之前写过一遍,那个方法没有彻底解决,现找到真正的解决方法 环境:redis 3.2.100 windows版(注意!!!这是关键),win10,redis客户端spring boot 2.0.7 ...

  10. git如何强制用远程分支更新本地

    git本地即使有修改如何强制更新: 本地有修改和提交,如何强制用远程的库更新本地.我尝试过用git pull -f,总是提示 You have not concluded your merge. (M ...