$HTTP_RAW_POST_DATA
这是手册里写的
总是产生变量包含有原始的 POST
数据。否则,此变量仅在碰到未识别 MIME 类型的数据时产生。不过,访问原始 POST 数据的更好方法是
php://input。$HTTP_RAW_POST_DATA 对于 enctype="multipart/form-data"
表单数据不可用。
问题: $HTTP_RAW_POST_DATA == $_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).
也
就是说,基本上$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"。
应用
------------------
<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"); ?>
随机推荐
- CodeforcesGym101116 B Bulbs
Description Greg has an \(m \times n\) grid of Sweet Lightbulbs of Pure Coolness he would like to tu ...
- Tomcat 架构 (一)
在实践过程中,从WebSphere中实现一个EJB的容器以及从WebLogic中实现一个JMS几乎都是不可能的,然而来自Apache基金会的servlet容器Tomcat至少在理论上是可能做到的. 请 ...
- 【 POJ - 1204 Word Puzzles】(Trie+爆搜|AC自动机)
Word Puzzles Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 10782 Accepted: 4076 Special ...
- qt5使用curl实现文件下载的示例程序 good
http://blog.csdn.net/xueyushenzhou/article/details/51702672#t3 http://download.csdn.net/detail/xueyu ...
- Android List<Map<String,String>转json(例子)
package com.armslee.json.test.cases; import java.util.ArrayList; import java.util.HashMap; import ja ...
- 【HDOJ】2414 Chessboard Dance
简单DFS. /* 2414 */ #include <cstdio> #include <cstring> #include <cstdlib> ; ][]; i ...
- bzoj3166
首先不难想到穷举次大数然后我们只要找到满足这个数是次大数的最大区间即可显然答案只可能是这两种[LL[i]+1,R[i]-1]和[L[i]+1,RR[i]-1]L[i]表示这个数ai左侧第一个比它大的数 ...
- 【转】在VMware中安装OS X Yosemite
原文网址:http://blog.gaohaobo.com/229.html OS X(前称:Mac OS X)操作系统是由苹果公司(Apple Inc.)为其Mac系列产品开发的.基于Unix的专属 ...
- 【转】在ubuntu环境下搭建svn server遇到的一些问题
原文网址:http://www.cnblogs.com/pcchinadreamfly/archive/2012/11/24/2786046.html 前段时间在ubuntu 12.04lts上倒腾了 ...
- Delphi webservice 定义 转
webservice Web Services是由企业发布的完成其特定商务需求的在线应用服务,其他公司或应用软件能够通过Internet来访问并使用这项在线服务. 简介 它是一种构建应用程序的普遍 ...