Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeshjangam/3be83ab9eedf3e5a12f6a1a4db24286f to your computer and use it in GitHub Desktop.
Save sandeshjangam/3be83ab9eedf3e5a12f6a1a4db24286f to your computer and use it in GitHub Desktop.
Useful debug function for developer
<?php
/**
* Create `help-vl.php` in php location and add below code in that file.
* Search `auto_prepend_file` in `php.ini`
* Replace it with file location `auto_prepend_file ="your-location\php\help-vl.php"`
*
*
*/
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">
div#adminmenuback {
display: none;
}
.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