http协议中,规定了数据可以post 或 get 上传,并且PHP解释器会自动将其解码,生成对应的 $_POST $_GET 变量,但能否同时用post 和 get 方式传数据呢?
今用 PHP5 实验了下,发现是可以的,http的请求头如下述形式:
POST /post-url-para.php?id=12345&w=2131 HTTP/1.1
Host: 192.168.1.9
Content-Type:application/x-www-form-urlencoded
Content-Length:16
name=wdh&a=123
第一行中的 /post-url-para.php?id=12345&w=2131 被“额外”解析为 $_GET 数据;
特别的,如果把POST 给为 GET 方式传,其它内容不变,则 post 中的内容 可以用 $raw_post_data = file_get_contents( 'php://input' ); 读取到,但没有解析为
$_POST 变量。