Andi Gutmans wrote: > At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: > >On Wed, 27 Nov 2002, Miham KEREKES wrote: > > > > > Hi! > > > > > > I'm new to this list, I want to know if there is any function which > > > could return the actual call stack, or is it planned to be added? > > > It could be very useful (for example in my case, now :-). > > > >debug_backtrace() will be available in PHP 4.3.0 and higher. > > if someone has time to implement debug_print_backtrace() that would be > cool. Using the raw debug_backtrace() is a bitch. > > Andi >
In case anyone's interested, here's what I use for my custom error handler: function __debug_error_handler($type, $msg, $file, $line, $context) { if (ini_get('html_errors')) { $hr = '<HR>'; $br = '<BR>'; $nbsp = ' '; $b = '<B>'; $slash_b = '</B>'; } else { $hr = "-----------------------\n"; $br = ''; $nbsp = ' '; $b = ''; $slash_b = ''; } echo $hr . ini_get('error_prepend_string'); $list = Array(E_USER_ERROR => 'U_ERROR', E_USER_WARNING => 'U_WARNING', E_USER_NOTICE => 'U_NOTICE', E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_NOTICE => 'NOTICE'); if (array_key_exists($type, $list)) { $type = $list[$type]; } else { $type = "UNKNOWN ERROR CODE ($type)"; } echo "$b$type:$slash_b $msg$br\n"; $bt = debug_backtrace(); $from = ''; for ($i = 1; $i < count($bt); ++$i) { $step = $bt[$i]; $class = isset($step['class']) ? $step['class'] . '::' : ''; if (empty($step['file'])) $step['file'] = ''; if (empty($step['line'])) $step['line'] = ''; printf("$nbsp$nbsp %s$b%s%s$slash_b [%s:%s]$br\n", $from, $class, $step['function'], $step['file'], $step['line'] ); $from = "$nbsp$nbsp$nbsp$nbsp from "; } echo ini_get('error_append_string'); } // __debug_error_handler -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php