Quick Variable Dump (HTML-friendly)
21
A quick and simple function to dump a variable (array, object, string, int, etc) out into -formatted output for a web browser.
If the variable is an array or an object, you can have it returned into the another variable for later processing (i.e., through templates or e-mail). Due to lack of free time, if the variable is not an array or an object, it will ignore the $return value and print directly to output.
Future revisions will add the above mentioned functionality.
If the variable is an array or an object, you can have it returned into the another variable for later processing (i.e., through templates or e-mail). Due to lack of free time, if the variable is not an array or an object, it will ignore the $return value and print directly to output.
Future revisions will add the above mentioned functionality.
function my_var_dump($variable, $return = FALSE) {
if (is_array($variable) || is_object($variable)) {
if ($return == TRUE) {
return sprintf("<pre>%s</pre>", print_r($variable, true));
} else {
printf("<pre>%s</pre>", print_r($variable, true));
return TRUE;
}
} else {
echo "<pre>";
var_dump($variable);
echo "</pre>";
}
}






There are currently no comments for this snippet.