$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. APP携参安装技术怎样帮助APP推广

    APP 如何自动实现携带参数安装?这是许多开发者感兴趣的问题,毕竟在 APP 开发的许多逻辑上常常不可避免的需要判断安装来源,比如:广告投放.用户邀请.用户行为.社交分享等 APP 推广环节,国内的 ...

  2. github最火的springboot开源学习资料

    https://github.com/JeffLi1993/springboot-learning-example https://github.com/ityouknow/spring-boot-e ...

  3. NET Core+MySql+Nginx

    NET Core+MySql+Nginx 容器化部署 .NET Core容器化@Docker.NET Core容器化之多容器应用部署@Docker-Compose.NET Core+MySql+Ngi ...

  4. Apache Atlas是什么?

    不多说,直接上干货! Apache Atlas是Hadoop社区为解决Hadoop生态系统的元数据治理问题而产生的开源项目,它为Hadoop集群提供了包括数据分类.集中策略引擎.数据血缘.安全和生命周 ...

  5. BigDecimal的加减乘除

    Java在java.math包中提供的API类BigDecimal,用来对超过16位有效位的数进行精确的运算.双精度浮点型变量double可以处理16位有效数.在实际应用中,需要对更大或者更小的数进行 ...

  6. 使用 h5 新特性,轻松监听任何 App 自带返回键

    var hiddenProperty = 'hidden' in document ? 'hidden' : 'webkitHidden' in document ? 'webkitHidden' : ...

  7. mitmweb的使用

    安装mitmproxy时带有mitmweb,可直接在命令行输入命令:mitmweb 此时可打开web界面.

  8. Python+selenium之fixtures

    fixtures即可以表示测试用例的开始和结束,也可以表示测试类和测试模块的开始和结束. import unittest def setUpModule(): print("test mod ...

  9. 使用github进行代码托管

    ---恢复内容开始--- 记录下使用github进行个人代码托管,github是公共的代码托管库,可以免费使用,由于是公共的所以大家都可以查看,如果是隐私重要的文件代码可以选择付费变为私有库 1.注册 ...

  10. 运行JavaWeb项目报错Access denied for user 'root'@'localhost' (using password: YES)

    问题重现:(以下讨论范围仅限Windows环境): C:\AppServ\MySQL> mysql -u root -p Enter password: ERROR 1045 (28000):  ...