コード例 #1
0
function smartDebug($variable, $description = 'Value', $nestingLevel = 0)
{
    # WARNING recursive
    $nestingLevelMax = 1;
    if ($debug_delay && $nestingLevel == -1) {
        global $sDebugResult;
        echo $sDebugResult;
    } else {
        if (!$nestingLevel) {
            addDebug("<ul type='circle' style='background:white; font-color:black; text-align:left; border:1px solid #a0a0a0;padding-bottom:4px;padding-right:4px'>\n<li>{" . getenv("REQUEST_URI") . "} ");
        }
        addDebug("<i>{$description}</i>: ");
        if (is_array($variable) || is_object($variable)) {
            if (is_array($variable)) {
                addDebug("(array)[" . count($variable) . "]");
            } else {
                addDebug("<B>(object)</B>[" . count($variable) . "]");
            }
            addDebug("<ul type='circle' style='border:1px solid #a0a0a0;padding-bottom:4px;padding-right:4px'>\n");
            foreach ($variable as $key => $value) {
                if ($nestingLevel > $nestingLevelMax) {
                    addDebug("<li>\"{$key}\"");
                    //        output ( "Nesting level $nestingLevel reached.\n" );
                } else {
                    addDebug("<li>\"{$key}\" => ");
                    smartDebug($value, '', $nestingLevel + 1);
                }
                addDebug("</li>\n");
            }
            addDebug("</ul>\n");
        } else {
            addDebug("(" . gettype($variable) . ") '{$variable}'\n");
        }
        if (!$nestingLevel) {
            addDebug("</li></ul>\n");
        }
    }
}
コード例 #2
0
ファイル: connect.php プロジェクト: kvervo/phplist-aiesec
function smartDebug($variable, $description = 'Value', $nestingLevel = 0)
{
    # WARNING recursive
    $nestingLevelMax = 1;
    if ($nestingLevel < 1) {
        $aBackTrace = debug_backtrace();
        $iIndex = count($aBackTrace) - 1;
        addDebug(sprintf("<ul>\n<li>{%s#%d:%s()} ", $aBackTrace[$iIndex]['file'], $aBackTrace[$iIndex]['line'], $aBackTrace[$iIndex]['function']));
    }
    addDebug("<i>{$description}</i>: ");
    if (is_array($variable) || is_object($variable)) {
        if (is_array($variable)) {
            addDebug("(array)[" . count($variable) . "]");
        } else {
            addDebug("<B>(object)</B>[" . count($variable) . "]");
        }
        addDebug("<ul type='circle' style='border:1px solid #a0a0a0;padding-bottom:4px;padding-right:4px'>\n");
        foreach ($variable as $key => $value) {
            if ($nestingLevel > $nestingLevelMax) {
                addDebug("<li>\"{$key}\"");
                //        output ( "Nesting level $nestingLevel reached.\n" );
            } else {
                addDebug("<li>\"{$key}\" => ");
                smartDebug($value, '', $nestingLevel ? $nestingLevel + 1 : 1);
            }
            addDebug("</li>\n");
        }
        addDebug("</ul>\n");
    } else {
        addDebug("(" . gettype($variable) . ") '{$variable}'\n");
    }
    if (!$nestingLevel) {
        addDebug("</li></ul>\n");
    }
    if (isset($debug_delay) && $debug_delay && $nestingLevel == -1 || $nestingLevel == 0) {
        global $sDebugResult;
        echo '<div id="dbg">' . $sDebugResult . '</div>';
        $sDebugResult = '';
    }
}
コード例 #3
0
ファイル: bdebuglib.php プロジェクト: kvervo/phplist-aiesec
function smartDebug($variable, $description = 'Value', $nestingLevel = 0) {
  # WARNING recursive
  global $sDebugResult;

  $nestingLevelMax = 5;

  if ($nestingLevel == 0) {
    addDebug("<div class='bbg'>\n");
    addDebug("<ul class='bbg_values'><a class='info'>\n");
  
    # Do a backtrace in a hidden span for tooltip
    $aBackTrace = debug_backtrace();
    addDebug("<span>\n");
    for($iIndex=1; $iIndex < count($aBackTrace); $iIndex++){
//    $iIndex = count($aBackTrace) - 4;
//    $iIndex = 2;

      addDebug(sprintf("\n<li>%s#%d:%s()</li> ",
      $aBackTrace[$iIndex]['file'],
      $aBackTrace[$iIndex]['line'],
      $aBackTrace[$iIndex]['function']));
    }
    addDebug("</span>\n");
  }
  
//  print "<br/>smartDebug($variable, $description , $nestingLevel) called";
  # Recurse into array or object
  if ($nestingLevel >= 0) {
  	addDebug("<i>$description</i>: ");
	  if (is_array($variable) || is_object($variable)) {
	    if (is_array($variable)) {
	      addDebug("(array)[" . count($variable) . "]");
	    } else {
	      addDebug("<B>(object)</B>[" . count($variable) . "]");
	    }
	    addDebug("<ul>\n");
	    foreach ($variable as $key => $value) {
	      if ($nestingLevel > $nestingLevelMax) {
	        addDebug("<li>\"{$key}\"");
	        //        output ( "Nesting level $nestingLevel reached.\n" );
	      } else {
	        addDebug("<li>\"{$key}\" => ");
	        smartDebug($value, '', $nestingLevel ? $nestingLevel + 1 : 1);
	      }
	      addDebug("</li>\n");
	    }
	    addDebug("</ul>\n");
	  } else
	    addDebug("(" . gettype($variable) . ") '{$variable}'\n");
	  if (!$nestingLevel)
	    addDebug("</li>\n");
  }
  
  # Wrap it nicely in a div
  if ( $nestingLevel == 0 ) {
    addDebug("</a></ul>\n");
  	addDebug("</div>\n");
  }

    # Print result when requested
  if ( $GLOBALS['config']['delay_debug_output'] && $nestingLevel == -1 
   || !$GLOBALS['config']['delay_debug_output'] && $nestingLevel == 0 ) {
   	echo $sDebugResult;
    $sDebugResult = '';
  }
}