Created
September 13, 2017 05:40
-
-
Save rushijagani/83ab0bd72a4a68d9d16a39abea92dc33 to your computer and use it in GitHub Desktop.
Function for Developers to debug the PHP code (var_dump/print_r)
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
if ( ! function_exists( 'vl' ) ) : | |
/** | |
* Replacement for print_r & var_dump. | |
* | |
* @param mixed $var | |
* @param bool $dump. (default: false) | |
*/ | |
function vl( $var, $dump = 0 ) { | |
?> | |
<style type="text/css"> | |
.vl_pre { | |
text-align: left; | |
margin: 30px 15px; | |
padding: 1em; | |
border: 0px; | |
outline: 0px; | |
font-size: 14px; | |
font-family: monospace; | |
vertical-align: baseline; | |
max-width: 100%; | |
overflow: auto; | |
color: rgb(248,248,242); | |
direction: ltr; | |
word-spacing: normal; | |
line-height: 1.5; | |
border-radius: 0.3em; | |
word-wrap: normal; | |
letter-spacing: 0.266667px; | |
background: rgb(61,69,75); | |
} | |
</style> | |
<?php | |
echo "<pre class='vl_pre'><xmp>"; | |
if ( true == $dump ) { | |
var_dump( $var ); | |
} else { | |
if ( is_array( $var ) || is_object( $var ) ) { | |
print_r( $var ); | |
} else { | |
echo $var; | |
} | |
} | |
echo "</xmp></pre>"; | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment