MaggsWeb:7

www.maggsweb.com

I usually write my own vars out to the screen for debugging using ‘print_r($_SESSION)’,'print_r($_POST)’etc inside <pre> tags, but this is awesome! (a little too much even). It’s like phpinfo(), but for your webpage!

<?php
function variable_array_dump($VARIABLE_NAME, $VARIABLE_ARRAY){
   if (is_array($VARIABLE_ARRAY)) {
      $output = "<table border='1'>";
      $output .= "<head><tr><td><b>" . $VARIABLE_NAME . "</b></td><td><b>VALUE</b></td></tr></head><body>";
      foreach ($VARIABLE_ARRAY as $key => $value) {
         $value = variable_array_dump($key, $value);
         $output .= "<tr><td>$key</td><td>$value</td></tr>";
      }
      $output .= "</body></table>";
      return $output;
   } else {return strval($VARIABLE_ARRAY);}
}
echo variable_array_dump('GLOBAL SERVER', $_SERVER);
echo variable_array_dump('GLOBAL ENV', $_ENV);
echo variable_array_dump('GLOBAL REQUEST', $_REQUEST);
echo variable_array_dump('GLOBAL GET', $_GET);
echo variable_array_dump('GLOBAL POST', $_POST);
echo variable_array_dump('GLOBAL COOKIE', $_COOKIE);
?>

If you want a simpler version, or need to just add something quick, try this:

 
echo '<pre>';
print_r($_GET);
print_r($_POST);
print_r($_SESSION);
echo 'end/pre';
Share this:
  • Print
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • Twitter

Write a Comment

Let me know what you think?