SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,384
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How do you style var_dump()?

    This does not color the var_dump() output red:

    Code:
    echo"<br><span style='color:red'>" . var_dump($sql) . "</span><br>";
    What's the correct syntax?
    Steve Husting

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,312
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    According to the var_dump docs, it doesn't return value. Instead, it outputs directly to the browser. Which means you'll either have to write it this way:

    echo "<br><span style='color:red'>";
    var_dump($sql);
    echo "</span><br>";


    Or, you could capture the var_dump's output using the output buffer functions.

    ob_start();
    var_dump($sql);
    $varDumpResult = ob_get_clean();

    echo "<br><span style='color:red'>" . $varDumpResult . "</span><br>";
    "First make it work. Then make it better."

  3. #3
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,384
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Pretty nice! Thanks for helping!
    Steve Husting

  4. #4
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    print_r($var, true);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •