A
A
Alan2018-03-15 12:27:56
PHP
Alan, 2018-03-15 12:27:56

How to make a beautiful var_dump in wordpress?

print_r-wordpress-post-pretty.png
Friends, who knows how to display such a readable var_dump (as in the picture)?
I set in wp-config.php define('WP_DEBUG', true); but still everything is displayed raw.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton, 2018-03-15
@Eridani

wrap in tag<pre>

A
Artem Spiridonov, 2018-03-15
@customtema

I don’t know about wordpress, but in general xdebug did it for php

D
Denis Yanchevsky, 2018-03-15
@deniscopro

You can make yourself a function with formatting, like this:

function vardump($var) {
  echo '<pre>';
  var_dump($var);
  echo '</pre>';
}

and use it instead of var_dump.
Once did something similar for print_r
function dco_print_r($expression, $return = false, $pre = true) {
    if ($pre) {
        echo '<pre>';
    }
    print_r($expression, $return);
    if ($pre) {
        echo '</pre>';
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question