[feature request] return name of current function
| From: | Martin Jansen | Date: | Fri, 23 Feb 2001 16:57:25 +0000 |
| Subject: | [feature request] return name of current function | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-47349@lists.php.net to get a copy of this message | ||
Hi
Is there anything that is speaking against a function
or a constant, that contains the name of the current
function?
This might be especially useful for situations like
<?php
function print_error($name) {
echo "An error occured in ".$name;
}
function foo() {
if ($error)
print_error('foo');
}
?>
where you pass the name of the function (in this
case the function, where the error occurs) to
another function. If there would be function or
a constant to return the current name, you could
simply type:
function foo() {
if ($error)
print_error(cur_function[()]);
}
So if you rename the function you do not need
to change the (perhaps multiple) call(s) for
print_error().
Martin