php $_POST 与 php://input的区别分析_PHP教程

WBOY
Release: 2016-07-20 11:09:50
Original
868 people have browsed it

$_POST 与 php教程://input可以取到值,$HTTP_RAW_POST_DATA 为空
$_POST 以关联数组方式组织提交的数据,并对此进行编码处理,如urldecode,甚至编码转换

php://input 也可以实现此这个功能可以获得POST的原始数据。

代码
echo file_get_contents( "php://input ");

实例





post.php

echo file_get_contents("php://input");?>


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


php $_POST

$_POST 变量是一个数组,内容是由 HTTP POST 方法发送的变量名称和值。

$_POST 变量用于收集来自 method="post" 的表单中的值。从带有 POST 方法的表单发送的信息,对任何人都是不可见的(不会显示在浏览器的地址栏),并且对发送信息的量也没有限制。

html


Enter your name:
Enter your age:

welcome.php

Welcome .

You are years old!

通过 HTTP POST 发送的变量不会显示在 URL 中。
变量没有长度限制


www.bkjia.com true http://www.bkjia.com/PHPjc/444770.html TechArticle $_POST 与 php教程://input可以取到值,$HTTP_RAW_POST_DATA 为空 $_POST 以关联数组方式组织提交的数据,并对此进行编码处理,如urldecode,甚至编码...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!