10

How can I print a $_POST?

Example:

echo $_POST['data'];

This returns nothing...

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
Victor Bjelkholm
  • 2,177
  • 9
  • 28
  • 50

3 Answers3

21

You can also wrap your code with <pre> tags to make your array prints out nicer instead of just 1 continuous line. A trick that was shown by a member on this site.

<pre>
<?php var_dump($_POST); ?>
</pre>
Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
Jamex
  • 732
  • 3
  • 9
  • 17
8

Your code is correct.

You can use either:

var_dump($_POST);

or

print_r($_POST);

to print out the entire POST array for debugging.

Tim Ridgely
  • 2,400
  • 1
  • 18
  • 25
2

You can only show the values of keys that exist. array_keys() returns an array containing the keys that exist in the array. If there is no output for a key despite the fact that the key exists then the array may contain an empty value for that key.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358