Created
August 1, 2016 06:01
-
-
Save jsoningram/51e8a097cb73be32fed124c7589d5af7 to your computer and use it in GitHub Desktop.
Better print_r and more flexible var_dump
This file contains 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 | |
class View_Variables { | |
public static function dump( $variables, $die = true ) { | |
if ( is_array( $variables ) ) { | |
foreach ($variables as $var ) { | |
var_dump( $var ); | |
} | |
} else { | |
var_dump( $variables ); | |
} | |
if ( $die ) { | |
die(); | |
} | |
} | |
public static function printr( $variables, $die = true ) { | |
echo '<pre>'; | |
if ( is_array( $variables ) ) { | |
foreach ( $variables as $key => $val ) { | |
echo $key . ': '; | |
print_r( $val ); | |
echo '<br>'; | |
} | |
} else { | |
print_r( $variables ); | |
} | |
echo '</pre>'; | |
if ( $die ) { | |
die(); | |
} | |
} | |
} | |
$view_variables = new View_Variables(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment