Ejemplo n.º 1
0
 /**
  * Makes debug output
  * Prints $var in bold between two vertical lines
  * If not $var the word 'debug' is printed
  * If $var is an array, the array is printed by t3lib_div::print_array()
  *
  * @param	mixed		Variable to print
  * @param	mixed		If the parameter is a string it will be used as header. Otherwise number of break tags to apply after (positive integer) or before (negative integer) the output.
  * @return	void
  */
 public static function debug($var = '', $brOrHeader = 0)
 {
     // buffer the output of debug if no buffering started before
     if (ob_get_level() == 0) {
         ob_start();
     }
     if ($brOrHeader && !div::testInt($brOrHeader)) {
         echo '<table class="debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;"><tr><td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">' . htmlspecialchars((string) $brOrHeader) . '</td></tr><tr><td>';
     } elseif ($brOrHeader < 0) {
         for ($a = 0; $a < abs(intval($brOrHeader)); $a++) {
             echo '<br />';
         }
     }
     if (is_array($var)) {
         div::print_array($var);
     } elseif (is_object($var)) {
         echo '<b>|Object:<pre>';
         print_r($var);
         echo '</pre>|</b>';
     } elseif ((string) $var != '') {
         echo '<b>|' . htmlspecialchars((string) $var) . '|</b>';
     } else {
         echo '<b>| debug |</b>';
     }
     if ($brOrHeader && !div::testInt($brOrHeader)) {
         echo '</td></tr></table>';
     } elseif ($brOrHeader > 0) {
         for ($a = 0; $a < intval($brOrHeader); $a++) {
             echo '<br />';
         }
     }
 }