I have a form that has multiple fields, and for testing purposes is there a way I could print out the values entered in all the fields, without having to individually print each value.
Simply: <? php print_r($_POST); //Or: foreach ($_POST as $key => $value) echo $key.
To print POST data array: echo print_r($_POST,true); If you want better legibility within a browser, wrap in <pre> tags.
Print FunctionThe Python print() function takes in any number of parameters, and prints them out on one line of text. The items are each converted to text form, separated by spaces, and there is a single '\n' at the end (the "newline" char).
PHP $_POST is a PHP super global variable which is used to collect form data after submitting an HTML form with method="post". $_POST is also widely used to pass variables. The example below shows a form with an input field and a submit button.
You should be able to do a var_dump($_REQUEST);
http://us2.php.net/manual/en/reserved.variables.request.php
http://us2.php.net/manual/en/function.var-dump.php
For extra credit, I always have:
function pre($data) {
print '<pre>' . print_r($data, true) . '</pre>';
}
Whenever I need to debug an array - which is very often - I just do pre($arr); to get a nicely formatted dump.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With