Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Echo an $_POST in PHP

Tags:

php

http-post

How can I print a $_POST?

Example:

echo $_POST['data'];

This returns nothing...

like image 293
Victor Bjelkholm Avatar asked Jun 08 '10 23:06

Victor Bjelkholm


3 Answers

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>
like image 132
Jamex Avatar answered Oct 14 '22 14:10

Jamex


Your code is correct.

You can use either:

var_dump($_POST);

or

print_r($_POST);

to print out the entire POST array for debugging.

like image 34
Tim Ridgely Avatar answered Oct 14 '22 12:10

Tim Ridgely


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.

like image 28
Ignacio Vazquez-Abrams Avatar answered Oct 14 '22 14:10

Ignacio Vazquez-Abrams