Make var_dump look pretty Make var_dump look pretty php php

Make var_dump look pretty


I really love var_export(). If you like copy/paste-able code, try:

echo '<pre>' . var_export($data, true) . '</pre>';

Or even something like this for color syntax highlighting:

highlight_string("<?php\n\$data =\n" . var_export($data, true) . ";\n?>");

You can do the same with print_r(). For var_dump() you would just need to add the <pre> tags:

echo '<pre>';var_dump($data);echo '</pre>';


Try xdebug extension for php.

Example:

<?php var_dump($_SERVER); ?>

Outputs:

enter image description here


Use preformatted HTML element

    echo '<pre>';        var_dump($data);    echo '</pre>';