function debug($note = null) { static $start_time = NULL; static $start_code_line = 0; global $debugf; $call_info = array_shift( debug_backtrace() ); $code_line = $call_info['line']; $file = array_pop( explode('/', $call_info['file'])); if( $start_time === NULL ) { $debug = "debug: ".$note." ".$file."> initialize
"; $start_time = time() + microtime(); $start_code_line = $code_line; return 0; } $debugf .= sprintf("debug: %s %s> Line: %d-%d time: %.4f mem: %d KB
", $note, $file, $start_code_line, $code_line, (time() + microtime() - $start_time), ceil( memory_get_usage()/1024)); $start_code_line = $code_line; } debug(); debug('All good'): debug('Something whent wrong'); echo $debugf;