Я отправляю как POST на страницу php следующее:
{a:1}
Это тело запроса (запрос POST).
Что мне нужно сделать в php, чтобы извлечь это значение?
var_dump($_POST);
не решение, не работает.
function getPost()
{
if(!empty([110]POST))
{
// when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request
// NOTE: if this is the case and [110]POST is empty, check the variables_order in php.ini! - it must contain the letter P
return [110]POST;
}
// when using application/json as the HTTP Content-Type in the request
$post = json_decode(file_get_contents('php://input'), true);
if(json_last_error() == JSON_ERROR_NONE)
{
return $post;
}
return [];
}
print_r(getPost());