DEV Community

Discussion on: Receive Data without $_GET,$_POST AND $_REQUEST

Collapse
 
timbryandev profile image
Tim Bryan

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.

Source with more detials: stackoverflow.com/a/8893792

Collapse
 
sandeepkamboj12 profile image
Sandeep kamboj

Yes. I basically used this to get JSON String.