A var_dump alternative

  October 28, 2016

I always find really hard-not-so-friendly  to read var_dump. So a while ago I found an alternative to display content with a coloured syntax.

I have to say that I didn’t code this and I don’t know the source. Here we go:

function dump($in = null) {
    echo '<pre style="
        white-space: pre-wrap;
        margin-left: 0px; 
        margin-right: 0px; 
        padding: 10px; 
        border: solid 5px rgba(50,50,50,.5); 
        background-color: ghostwhite; 
        color: black; 
        text-align: left;">';
    foreach ( func_get_args() as $var ) {
        echo "\n";
        if ( is_string($var) ) {
            echo "$var\n";
        } else {
    echo '</ pre>'."\n";
    return $in;
} # dump()

Remove the space on the final 🙂