Receive JSON POST with PHP

前端 未结 7 2335
Happy的楠姐
Happy的楠姐 2020-11-21 04:42

I’m trying to receive a JSON POST on a payment interface website, but I can’t decode it.

When I print :

echo $_POST;

I get:

7条回答
  •  一向
    一向 (楼主)
    2020-11-21 05:27

    If you already have your parameters set like $_POST['eg'] for example and you don't wish to change it, simply do it like this:

    $_POST = json_decode(file_get_contents('php://input'), true);
    

    This will save you the hassle of changing all $_POST to something else and allow you to still make normal post requests if you wish to take this line out.

提交回复
热议问题