Keys →
Functions ↓
function stackTrace($v=2,$h=0) {#-k debug trace#- returns the stack traceback as a syntax-highlighted string.#- $v == 0: just return the stack#- 1: stack, args and lines#- 2: stack and args#- $h == 0: don't highlight syntax, use \n#- 1: highlight syntax, use <br>#- Example output:#- Stack Trace(2):#-#- [0-binSearch] utils.php:89#- Line 89: |prt ( stackTrace(), 1) ;|# [0-MAIN] zipload.php:43#-#- [1-MAIN] zipload.php:43#- Line 43: |$i = binSearch ( $zip, $z ); ### shd return 0, not 5|#- 0: |Array|#- 1: |00000| $output = '<br><br><b>stackTrace:</b><pre><br>'; $maxflen = 0; $blanks = ' !'; $raw = debug_backtrace(); # [0] is the guy who called me for ($i=0;$i<count($raw);$i++) { $entry = $raw[$i]; if (isset($raw[$i+1]['function'])) { $nf = $raw[$i+1]['function']; } else { $nf = 'MAIN'; } $arr = explode ( '/', $entry['file'], 30 ); # get filename $output .= '[' . $i . '-<b>' . $nf . '</b>] ' . $arr[count($arr)-1] . ':' . $entry['line'] . '<br>'; if ($v) { $line = file ( 'file://' . $entry['file'] ); $codeline = trim($line[$entry['line']-1]); if ($h ) { $codeline = highlight_string('<' . '?php' . $codeline . '?' . '>', true); } $cl = ''; for ($k = 0; $k < strlen($codeline); $k++ ) if (ord(substr($codeline,$k,1)) != 10) $cl .= substr($codeline,$k,1); $junk = array ( '<code>', '</code>', '<?php', '?>' ); $codeline = str_replace( $junk, '', $cl ); $output .= substr($blanks,0,$maxflen+2) . 'Line ' . sprintf("% 4d", $entry['line']) . ': |' . $codeline . '|<br>'; if ($v>1) { $j = 0; foreach ($entry['args'] as $arg) { $output .= substr($blanks,0,$maxflen+10) . $j . ': |' . $arg . '|<br>'; $j++; } } } } if (!$h) $output = str_replace ( '<br>', "\n", $output ); return $output . '</pre>'; }?>