Make var_dump look pretty

后端 未结 14 2429
忘掉有多难
忘掉有多难 2020-12-02 04:23

I have a simple $_GET[] query var set for showing testing data when pulling down queries from the DB.


  <         


        
相关标签:
14条回答
  • 2020-12-02 04:45

    Use

    echo nl2br(var_dump());
    

    This should work ^^

    0 讨论(0)
  • 2020-12-02 04:47

    You could use this one debugVar() instead of var_dump()

    Check out: https://github.com/E1NSER/php-debug-function

    0 讨论(0)
  • 2020-12-02 04:47

    There is a Symfony package for this: https://symfony.com/doc/current/components/var_dumper.html.

    0 讨论(0)
  • 2020-12-02 04:49

    If it's "all smushed together" you can often give the ol' "view source code" a try. Sometimes the dumps, messages and exceptions seem like they're just one long string when it turns out that the line breaks simply don't show. Especially XML trees.

    Alternatively, I've once created a small little tool called InteractiveVarDump for this very purpose. It certainly has its limits but it can also be very convenient sometimes. Even though it was designed with PHP 5 in mind.

    0 讨论(0)
  • 2020-12-02 04:51

    Use preformatted HTML element

    echo '<pre>';
    var_dump($data);
    echo '</pre>';
    
    0 讨论(0)
  • 2020-12-02 04:58

    Try xdebug extension for php.

    Example:

    <?php var_dump($_SERVER); ?>
    

    Outputs:

    enter image description here

    0 讨论(0)
提交回复
热议问题