7     public static function newFunction($sHeading)
 
   9         echo "<pre><h2>Debug output for $sHeading</h2></pre>\n";
 
  12     public static function newSection($sHeading)
 
  14         echo "<hr><pre><h3>$sHeading</h3></pre>\n";
 
  17     public static function printVar($sHeading, $mVar)
 
  19         echo '<pre><b>'.$sHeading. ':</b>  ';
 
  20         Debug::outputVar($mVar, str_repeat(' ', strlen($sHeading) + 3));
 
  24     public static function fmtArrayVals($aArr)
 
  26         return array('__debug_format' => 'array_vals', 'data' => $aArr);
 
  29     public static function printDebugArray($sHeading, $oVar)
 
  33             Debug::printVar($sHeading, 'null');
 
  35             Debug::printVar($sHeading, $oVar->debugInfo());
 
  39     public static function printDebugTable($sHeading, $aVar)
 
  41         echo '<b>'.$sHeading.":</b>\n";
 
  42         echo '<table border="1">';
 
  46             $aInfo = reset($aVar);
 
  47             if (!is_array($aInfo)) {
 
  48                 $aInfo = $aInfo->debugInfo();
 
  50             foreach ($aInfo as $sKey => $mVal) {
 
  51                 echo '<th><small>'.$sKey.'</small></th>';
 
  55             foreach ($aVar as $oRow) {
 
  57                 if (!is_array($oRow)) {
 
  58                     $aInfo = $oRow->debugInfo();
 
  61                 foreach ($aKeys as $sKey) {
 
  63                     if (isset($aInfo[$sKey])) {
 
  64                         Debug::outputVar($aInfo[$sKey], '');
 
  74     public static function printGroupTable($sHeading, $aVar)
 
  76         echo '<b>'.$sHeading.":</b>\n";
 
  77         echo '<table border="1">';
 
  79             echo '<tr><th><small>Group</small></th>';
 
  81             $aInfo = reset(reset($aVar));
 
  82             if (!is_array($aInfo)) {
 
  83                 $aInfo = $aInfo->debugInfo();
 
  85             foreach ($aInfo as $sKey => $mVal) {
 
  86                 echo '<th><small>'.$sKey.'</small></th>';
 
  90             foreach ($aVar as $sGrpKey => $aGroup) {
 
  91                 foreach ($aGroup as $oRow) {
 
  93                     if (!is_array($oRow)) {
 
  94                         $aInfo = $oRow->debugInfo();
 
  96                     echo '<tr><td><pre>'.$sGrpKey.'</pre></td>';
 
  97                     foreach ($aKeys as $sKey) {
 
  99                         if (!empty($aInfo[$sKey])) {
 
 100                             Debug::outputVar($aInfo[$sKey], '');
 
 111     public static function printSQL($sSQL)
 
 113         echo '<p><tt><font color="#aaa">'.$sSQL.'</font></tt></p>'."\n";
 
 116     private static function outputVar($mVar, $sPreNL)
 
 118         if (is_array($mVar) && !isset($mVar['__debug_format'])) {
 
 120             foreach ($mVar as $mKey => $aValue) {
 
 122                 $iKeyLen = Debug::outputSimpleVar($mKey);
 
 126                     $sPreNL.str_repeat(' ', $iKeyLen + 4)
 
 128                 $sPre = "\n".$sPreNL;
 
 130         } elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
 
 131             if (!empty($mVar[data])) {
 
 133                 foreach ($mVar[data] as $mValue) {
 
 135                     Debug::outputSimpleVar($mValue);
 
 140             Debug::outputSimpleVar($mVar);
 
 144     private static function outputSimpleVar($mVar)
 
 146         if (is_bool($mVar)) {
 
 147             echo '<i>'.($mVar ? 'True' : 'False').'</i>';
 
 148             return $mVar ? 4 : 5;
 
 151         if (is_string($mVar)) {
 
 153             return strlen($mVar) + 2;
 
 157         return strlen((string)$mVar);