Go to content

Pretty PHP dumps using highlight_string()

Robin Nilsson · 20 August 2018 · php

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