(forw) How to get a stacktrace at runtime?
| From: | Alfred Perlstein | Date: | Thu, 23 Mar 2000 07:59:03 +0000 |
| Subject: | (forw) How to get a stacktrace at runtime? | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12517@lists.php.net to get a copy of this message | ||
Maybe this is a better list to ask for enhancements?
thanks,
----- Forwarded message from Alfred Perlstein <bright@wintelcom.net> -----
Date: Wed, 22 Mar 2000 16:03:19 -0800
From: Alfred Perlstein <bright@wintelcom.net>
To: php3@lists.php.net
Subject: How to get a stacktrace at runtime?
Message-ID: <20000322160319.B21029@fw.wintelcom.net>
X-Mailer: Mutt 1.0.1i
Hey guys, I've been trying to abstract a lot of my code with regards
to database connectivity and other such things, so instead of
calling 'mysql_foo()' I include a database.php file and use
'database_foo()' which in turn calls mysql_foo().
Anyhow, here comes the difficult part, I'd like to be able to get
a traceback at runtime, meaning, i'd like to be able to figure out
at runtime from which file, function and line 'database_foo' was
called from.
Otherwise it makes it awfully difficult to debug without using the
debugger which would be overkill for my situation.
I'd also like to trap errors and email myself backtraces... so...
Basically, if I'd like to be able to do something like this:
function daatbase_foo() {
echo "I was called from file: $STACK[1]["file"] line
$STACK[1]["line"]";
}
or perhaps even:
echo "traceback:\n"
$c = count($STACK);
for ($i = 0; $i < $c; $i++) {
echo
"$STACK[$i]["file"]:$STACK[$i]["function"]:$STACK[$i]["line"]\n";
}
Does such fucntionality exist? If not, is it planned?
I'd really love to see this kind of thing in php if possible.
thanks,
--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
----- End forwarded message -----