Pretty PHP dumps using highlight_string()

Robin Nilsson • August 20, 2018

php snippets

This is a nice little trick if you’re sick of the almost impossible to read var_dump.

function dump($data) {
    highlight_string("<?php\n" . var_export($data, true) . "\n");
}
<?php dump(['foo' => 'bar', 'baz' => 'foobar', 'status' => true]); ?>

And it should come out something like this. Nice, eh?

Highlighted PHP code