How to read a post request without knowing the variables?

I am trying to read a message sent from a client using PHP whether they pass variables or not. I want to read the message data. I tried using, without any luck:

 echo file_get_contents('php://input'); 

I tried to send a request to send http://posttestserver.com/ , and the HTTP Post returns 200 and shows the mail data sent to it.

How can I do this using php?

+7
post php
source share
1 answer

You can read the message data from the $_POST variable. If you want to know which keys are stored in an array, use array_keys () :

 $postKeys = array_keys($_POST); 

Alternatively, you can use foreach to scan the array:

 foreach ($_POST as $key => $value) { echo "Key: $key; Value: $value\n"; } 
+12
source share

All Articles