Php 当GET和POST发送相同的值时,将返回什么$\u请求?

Php 当GET和POST发送相同的值时,将返回什么$\u请求?,php,forms,post,get,Php,Forms,Post,Get,我试图在PHP中创建一个表单,我使用用户ID通过GET在表单中显示数据,但通过POST提交表单后,我将用户ID存储在一个隐藏字段中 在尝试这一点时,我只是把GET、POST和REQUEST弄糊涂了 看到这种情况了吗 <form action="script.php?id=777" method="post"> ID: <input type="text" name="id" /> <input type="submit" value="Send"

我试图在
PHP
中创建一个表单,我使用用户ID通过GET在表单中显示数据,但通过POST提交表单后,我将用户ID存储在一个隐藏字段中

在尝试这一点时,我只是把
GET
POST
REQUEST
弄糊涂了

看到这种情况了吗

<form action="script.php?id=777" method="post">
     ID: <input type="text" name="id" />
     <input type="submit" value="Send" />
</form>

身份证件:
假设我在文本字段中输入'888' 提交此表单时,请求['id']的值是多少应该提供什么

在所有
php版本中都是相同的

如果我将文本字段留空会发生什么

如果我将操作更改为
action=“script.php?id=“

01

如果表单处于
post
方法中

<form action="script.php" method="post">
     ID: <input type="text" name="id" />
     <input type="submit" value="Send" />
</form>
<form action="script.php" method="get">
     ID: <input type="text" name="id" />
     <input type="submit" value="Send" />
</form>
02

如果表单处于
get
方法中

<form action="script.php" method="post">
     ID: <input type="text" name="id" />
     <input type="submit" value="Send" />
</form>
<form action="script.php" method="get">
     ID: <input type="text" name="id" />
     <input type="submit" value="Send" />
</form>

您可以参考PHP.ini文件中的“request\u order”设置来确定实际顺序

; This directive determines which super global data (G,P,C,E & S) should
; be registered into the super global array REQUEST. If so, it also determines
; the order in which that data is registered. The values for this directive are
; specified in the same manner as the variables_order directive, EXCEPT one.
; Leaving this value empty will cause PHP to use the value set in the
; variables_order directive. It does not mean it will leave the super globals
; array REQUEST empty.
; Default Value: None
; Development Value: "GP"
; Production Value: "GP"
; http://php.net/request-order
request_order = "GP"

通常默认设置为Get then Post。在本例中,您将id参数作为get和post参数提供。这意味着$\u请求首先填充$\u GET,然后填充$\u POST。意思是$\u请求将反映$\u POST。

您是否无法在您的终端检查此项。要花多少时间?有时会出人意料地起作用。。我只是想确定这有什么规定。这样我就可以在项目中使用它之前依赖它了。最好不要使用
$\u REQUEST
。为什么-Thnx,但我只是想知道,如果
'?id=1'
在url中,并且
id=2
是通过邮件发送的,那么
$\u请求[''id]=?
。好的,这意味着我不能依赖它总是给出
=1
,因为我有时尝试过它给出
=2
。Thnx@Ronald。。这就是为什么它在不同的系统中工作不同,背后有技术支持。thnx。