php的HTTP_RAW_POST_DATA(转)
2009-06-15 09:56
381 查看
原文地址: http://www.phpman.com.cn/archives/143
用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"); ?>
用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"); ?>
相关文章推荐
- 区别 PHP 的 $_POST、$HTTP_RAW_POST_DATA 和 php://input
- php: Undefined index: HTTP_RAW_POST_DATA
- 【PHP】$_POST, $HTTP_RAW_POST_DATA, and php://input
- $POST 、$HTTP_RAW_POST_DATA、php://input三者之间的区别
- $POST 、$HTTP_RAW_POST_DATA、php://input三者之间的差别
- 谈谈$_POST、$GLOBALS['HTTP_RAW_POST_DATA']和file_get_contents('php://input')
- PHP的"php://input"和$HTTP_RAW_POST_DATA 和$_POST的关系
- php获取post的数据$HTTP_RAW_POST_DATA
- 分答项目_知识点:php://input $POST $HTTP_RAW_POST_DATA三者之间的关系
- php://input &$GLOBALS["HTTP_RAW_POST_DATA"]&$_POST
- php中php://input、$_POST和$HTTP_RAW_POST_DATA的异同
- 说说$POST 、$HTTP_RAW_POST_DATA、php://input三者之间的区别
- PHP中除了POST和GET之外还有$HTTP_RAW_POST_DATA 以及和$_POST的区别
- PHP-"php://(类型)"访问各个输入/输出流以及全局变量$HTTP_RAW_POST_DATA讲解
- 说说$POST 、$HTTP_RAW_POST_DATA、php://input三者之间的区别
- $POST 、$GLOBALS['HTTP_RAW_POST_DATA']、php://input三者之间的区别
- $POST、$HTTP_RAW_POST_DATA、php://input区别
- php://input,$_POST,$HTTP_RAW_POST_DATA区别
- php 对http内容的解析 $_POST php://input $HTTP_RAW_POST_DATA
- POST, HTTP_RAW_POST_DATA, and php://input