/ Published in: PHP
When working in PHP I sometimes want to know exactly what is in a variable. This is easy enough to find out, but having this function around it is even easier, as it includes the HTML pre tag making it easier to read, and it allows you to choose how it should be debugged (defaults to using print_r()).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
{ function debug($var, $fn='print_r') { { echo '<pre>', $fn($var), '</pre>'; } else { echo '<pre>The function ', $fn, '() does not exist. Falling back to', } } } // Example /* <pre>Array ( [0] => test1 [1] => 123 ) 1</pre> */