$_POST 与 php://input

总结:

  1. 当 HTTP POST 请求的 Content-Type 是 application/x-www-form-urlencoded:php://input 中是形同 a=1&b=2的原始数据。$_POST 中是关联数组(常规的post表单提交、ajax默认post提交)
  2. 提交表单时。 enctype="multipart/form-data" 的时候php://input 是无效的
  3. $_POST 不能获取 Content-Type = "text/plain"时 post的数据, php://input可以
  4. 另外:基本上$GLOBALS['HTTP_RAW_POST_DATA'] 和 $_POST是一样的。但是如果post过来的数据不是PHP能够识别的,你可以用 $GLOBALS['HTTP_RAW_POST_DATA'] 或者 $HTTP_RAW_POST_DATA 来接收,比如 text/xml 或者 soap 等等。

猜你喜欢

转载自blog.csdn.net/weixin_38230961/article/details/103157230
今日推荐