Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Created October 10, 2013 06:32
Show Gist options
  • Save adamsilverstein/6913975 to your computer and use it in GitHub Desktop.
Save adamsilverstein/6913975 to your computer and use it in GitHub Desktop.
This function will print a stack telling you where it was called from. See http://stackoverflow.com/questions/708140/php-fatal-error-cannot-redeclare-class.
function PrintTrace() {
$trace = debug_backtrace();
echo '<pre>';
$sb = array();
foreach($trace as $item) {
if(isset($item['file'])) {
$sb[] = htmlspecialchars("$item[file]:$item[line]");
} else {
$sb[] = htmlspecialchars("$item[class]:$item[function]");
}
}
echo implode("\n",$sb);
echo '</pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment