php中的用户数据
数据类型编码器类型发送方式接收数据
查询字符串

application/x-www-form-urlencoded

get、post

$_REQUEST、

$_GET、

$_POST、
file_get_contents('php://input')、

$GLOBALS['HTTP_RAW_POST_DATA']

文件multipart/form-datapost$_FILES

普通字符串

(如:json字符串、xml字符串)

application/x-www-form-urlencodedpost

file_get_contents('php://input')、

$GLOBALS['HTTP_RAW_POST_DATA']

FormData对象(包含文件)multipart/form-data
post
$_REQUEST、$_POST、$_FILES
数组(包含文件)
multipart/form-datapost$_REQUEST、$_POST、$_FILES


发送用户数据的地方:

  • url:查询字符串,始终以get方式发送

  • html表单:查询字符串、文件,发送文件必须设置编码器类型为multipart/form-data

  • ajax:查询字符串、json字符串、xml字符串、FormData对象(包含文件)

  • fetch:查询字符串、json字符串、xml字符串、FormData对象(包含文件)

  • curl:查询字符串、json字符串、xml字符串、数组(包含文件)


发送的数据要进行url编码:

  • url的编码规则不同浏览器采用不同的编码规则

  • 表单数据的编码规则同页面编码

  • ajax数据的编码规则同页面编码

  • curl数据的编码规则同页面编码



说明:

file_get_contents('php://input')、$GLOBALS['HTTP_RAW_POST_DATA']接收的条件:application/x-www-form-urlencoded和post。