Search code examples
phppostrequestpayload

Reading Request Payload in PHP


How can I read content of Request Payload (POST) using PHP?

I´m using a Angular aplication to send the POST.

I've tried with: $_POST, $_FILES and file_get_contents('php://input') ...

None worked.


Solution

  • If you need view x-www-form-urlencoded post data, just use

    print_r($_POST);
    

    If you need view json post data, use this

    $data=json_decode(file_get_contents('php://input'),1);
    print_r($data);