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.
You should be able to do a var_dump($_REQUEST);
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.
print_r() / var_dump() are simple and gets the job done.
If you want a styled/dynamic option check out Krumo:
A lot of developers use print_r() and var_dump() ... Krumo is an alternative: it does the same job, but it presents the information beautified using CSS and DHTML.
Besides using inline debug statements, you could also considering transient debugging, i.e. you could use an IDE with debug capabilities, like eclipse or zend studio. This way you could watch any variable you'd like to.
bye!
This PHP code doesn't require any knowledge of the fields in the form that submits to it, it just loops through all of the fields, including multiple-choice fields (like checkboxes), and spits out their values.
<?php
// loop through every form field
while( list( $field, $value ) = each( $_POST )) {
// display values
if( is_array( $value )) {
// if checkbox (or other multiple value fields)
while( list( $arrayField, $arrayValue ) = each( $value ) {
echo "<p>" . $arrayValue . "</p>\n";
}
} else {
echo "<p>" . $value . "</p>\n";
}
}
?>