For context, here is why it works and how it is different from from Post, Get and Request (mainly Post):
The PHP superglobal $_POST, is only supposed to wrap data that is either
application/x-www-form-urlencoded (standard content type for simple form-posts) or
multipart/form-data-encoded (mostly used for file uploads)
This is because these are the only content types that must be supported by user agents.
By contrast, file_get_contents('php://input'); will get all the raw data from the request regardless of its type and is left for you to interpret/parse as you will.
For context, here is why it works and how it is different from from Post, Get and Request (mainly Post):
The PHP superglobal
$_POST
, is only supposed to wrap data that is eitherapplication/x-www-form-urlencoded
(standard content type for simple form-posts) ormultipart/form-data-encoded
(mostly used for file uploads)This is because these are the only content types that must be supported by user agents.
By contrast,
file_get_contents('php://input');
will get all the raw data from the request regardless of its type and is left for you to interpret/parse as you will.Source with more detials: stackoverflow.com/a/8893792
Yes. I basically used this to get JSON String.