更新时间:2023-08-20 12:39:10
参见 $_POST
文档 说的是:
See the $_POST
documentation which says it is:
使用 application/x-www-form-urlencoded
或 multipart/form 时通过 HTTP
作为请求中的 HTTP POST
方法传递给当前脚本的关联变量数组-dataContent-Type
.
An associative array of variables passed to the current script via the HTTP
POST
method when usingapplication/x-www-form-urlencoded
ormultipart/form-data
as the HTTPContent-Type
in the request.
但你不是在执行 x-www-form-urlencoded
请求.您正在执行 application/json
请求.所以你不能使用 $_POST
.使用 php://input
(例如,正如这里所讨论的:iOS 发送 JSON 数据在使用 NSJSONSerialization 的 POST 请求中).
But you're not doing x-www-form-urlencoded
request. You're performing an application/json
request. So you can't use $_POST
. Use php://input
(e.g., as discussed here: iOS Send JSON data in POST request using NSJSONSerialization).