miguel.nz

A var_dump alternative

October 28, 2016   |   1 minute read.

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 '
';
    foreach ( func_get_args() as $var ) {
        echo "\n";
        if ( is_string($var) ) {
            echo "$var\n";
        } else {
            var_dump($var);
        }
    }
    echo ''."\n";
    return $in;
} # dump()

Remove the space on the final 🙂