PHP - getting content of the POST request
I have problem with getting the content. I don't know the names of the post variables so I can't do this using
$variable = $_POST['name'];
because I don't know the "name". I want to catch all of the variables sent by POST method.
How can I get keys of the $_POST[]
array and the correspond开发者_如何学JAVAing values?
Standard for-each:
foreach ($_POST as $key => $value)
{
// ... Do what you want with $key and $value
}
$_POST is just a big array:
while(list($keys,$vars) = each($_POST)){ // do something. }
for some quick debugging, you can also use
print_r ($_POST)
Just use a for each loop
foreach($_POST as $key => $value){
echo "$key = $value";
}
Besides print_r($_POST);
you could also use var_dump($_POST);
, but most logical solution as mentioned earlier is foreach
loop.
basically post request will be mapped to array. for debuging you can call
var_dump($_POST);
this code will list all array within post array.
To get the keys:
array_keys($_POST);
精彩评论