News:

Wondering if this will always be free?  See why free is better.

Main Menu

Tips: debug box

Started by AzaToth, October 17, 2005, 12:31:54 PM

Previous topic - Next topic

AzaToth

made this little function to show me debug info in one place instead of flowing it out in the page:

function debug($data, $print = false) {
static $debug_content;
$debug_content[] =  '<pre>'.htmlspecialchars(print_r($data,true)).'</pre>';
if($print) {
echo '<div id="debug" '.
'style="color: #aabdff; position: fixed; z-index: 3; top: 0px; left: 0px; font-weight: bold; max-width: 30%; padding: 0.1em; background-color: #334444;">'.
'<div onclick="i = this.nextSibling; i.style.display = i.style.display == \'none\' ? \'\' : \'none\';" '.
'style="border-bottom: 1px solid gray; cursor: pointer;">Debug</div>'.
'<div style="display: none; overflow: auto; max-height: 600px; background-color: #445555; padding: 0.3em;">';
echo implode("\n",$debug_content);
echo '</div></div>';
}
}


set print to true at the last call to debug

Example:

debug(array('a' => 'b'));
debug(array('c' => 'd'));
debug('hallo',true);

Advertisement: