POST和POST中的原始POST之间有什么区别? [英] What's the difference between POST and raw POST in PHP at all?
问题描述
在阅读答案后,我有这个问题这里,有什么不同?
是否可以使用html提交原始POST?
我们可以在三种情况下分割表单提交:
- 内容类型
application / x-www-form-urlencoded
- 内容类型
multipart / form-data
- 其他提交。
- Submissions with content type
application/x-www-form-urlencoded
- Submissions with content type
multipart/form-data
- Other submissions.
在情况1和3中, $ HTTP_RAW_POST_DATA
包含原始发布数据(除非选项为 always_populate_raw_post_data
设置为 false
,在这种情况下,<1 $ c $> $ HTTP_RAW_POST_DATA 在情况1)中为空,即与客户端(通常是浏览器)发送的数据完全相同。在情况1中,数据具有诸如以下形式:
key1 = value1& key2 = value2& key3 [] = value3。 1& key3 [] = value3.2
PHP会自动解析它,所以 $ _ POST
变成:
$ _ POST = array(
key1=> ;value1,
key2=>value2,
key3=>数组(value3.1,value3.2);
)
原始数据的内容也可以通过 php://输入
,即使在情况1中,当 always_populate_raw_post_data
被设置为 false
时。特别是, file_get_contents(php:// input)
给出了相同的数据 $ HTTP_RAW_POST_DATA
已经或将要拥有的数据。
在情况3中,POST数据是任意的, $ _ POST
将是一个空数组,< c $ c> $ HTTP_RAW_POST_DATA 将始终填充。
案例2是一个特例。在这种情况下,PHP将解析数据,并且 $ _ POST
将获取未上传文件的字段内容,但是 php:// input
和 $ HTTP_RAW_POST_DATA
将不可用。
I have this question after reading the answer here, what's the difference at all?
Is it possible to submit raw POST with html ?
We can divide form submissions in three cases:
In cases 1 and 3, $HTTP_RAW_POST_DATA
contains the raw post data (except if the option is always_populate_raw_post_data
is set to false
, in which case $HTTP_RAW_POST_DATA
is empty in case 1), i.e., the data exactly as the client (usually the browser) has sent it. In case, 1, the data has a form such as
key1=value1&key2=value2&key3[]=value3.1&key3[]=value3.2
PHP automatically parses this, so that $_POST
becomes:
$_POST = array(
"key1" => "value1",
"key2" => "value2",
"key3" => array("value3.1", "value3.2");
)
The contents of the raw data can also be access through php://input
, even in case 1 when always_populate_raw_post_data
is set to false
. In particular, file_get_contents("php://input")
gives the same data $HTTP_RAW_POST_DATA
has or would have.
In case 3, in which the POST data is arbitrary, $_POST
will be an empty array and $HTTP_RAW_POST_DATA
will always be populated.
Case 2 is a special one. In that case, PHP will parse the data and $_POST
will get the content of the fields which are not uploaded files, but php://input
and $HTTP_RAW_POST_DATA
will be unavailable.
这篇关于POST和POST中的原始POST之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!