Skip to content

Instantly share code, notes, and snippets.

@LucaRosaldi
Created December 17, 2012 12:19
Show Gist options
  • Save LucaRosaldi/4317902 to your computer and use it in GitHub Desktop.
Save LucaRosaldi/4317902 to your computer and use it in GitHub Desktop.
PHP: Pretty Print function (for debugging)
<?php
/**
* Pretty Print (for debugging)
* @param mixed value to print
*/
function pp($val = null) {
if ( $val === false ) {
echo '<pre>(boolean) 0</pre>';
}
elseif ( empty($val) ) {
echo '<pre>null</pre>';
}
elseif ( is_array($val) || is_object($val) ) {
echo '<pre>';
print_r($val);
echo '</pre>';
}
else {
echo '<pre>('.gettype($val).') '.$val.'</pre>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment