Created
June 25, 2012 13:14
-
-
Save tareq1988/2988483 to your computer and use it in GitHub Desktop.
a debugging function for php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !function_exists( 'wp_print_r' ) ) { | |
/** | |
* Debugging function | |
* | |
* @param mixed $var the variable name | |
* @param string $title title of the variable | |
* @param bool $die if to die or not | |
*/ | |
function wp_print_r( $var, $title = '', $die = false ) { | |
if ( !empty( $title ) ) { | |
printf( '<h3>%s</h3>', $title ); | |
} | |
if ( extension_loaded( 'xdebug' ) ) { | |
var_dump( $var ); | |
} else { | |
printf( '<pre>%s</pre>', print_r( $var, true ) ); | |
} | |
if ( $die ) { | |
die(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment