__FILE__ and __LINE__ in functions
| From: | Eden Li | Date: | Tue, 25 Jul 2000 21:35:16 +0000 |
| Subject: | __FILE__ and __LINE__ in functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-8148@lists.php.net to get a copy of this message | ||
Is it possible to get the file and line number a user-defined function was
called
from? Something similar to caller() in Perl. Here's an example:
function error_func ($message = '')
{
echo "Error occurred at ", /* LINE NUMBER */, " in ", /* FILE NAME */, "
on
", date ("n/j/y h:i:s"), ": $message";
}
__LINE__ and __FILE__ only return the line and file the function is
contained in, and
the PHP manual doesn't seem to make mention of this, and error_log()
doesn't do line/file
reporting. Is it at all possible in PHP or am I stuck? If I am, where can
I make a request
for such a feature to be implemented in a future version of PHP?
Any help/comments/suggestions would be appreciated.
--
Eden Li
eden@adv-computer.com