How to get body of a POST in php?

后端 未结 8 1984
小蘑菇
小蘑菇 2020-11-22 01:25

I submit as POST to a php page the following:

{a:1}

This is the body of the request (a POST request).
In php, what do I have to do to

8条回答
  •  萌比男神i
    2020-11-22 01:52

    A possible reason for an empty $_POST is that the request is not POST, or not POST anymore... It may have started out as post, but encountered a 301 or 302 redirect somewhere, which is switched to GET!

    Inspect $_SERVER['REQUEST_METHOD'] to check if this is the case.

    See https://stackoverflow.com/a/19422232/109787 for a good discussion of why this should not happen but still does.

提交回复
热议问题