Intro:
For functions you would use __FUNCTION__
(linked) and for class methods you can use __METHOD__
(linked).
Function:
function my_function() {
echo __FUNCTION__;
}
Output would be my_function
;
Class Method:
class Treffynnon {
public function my_method() {
echo __METHOD__;
}
}
Output would be my_method
;
Display a function as it was called:
function my_function($param1, $param2, $param3) {
$args = func_get_args();
echo __FUNCTION__ . '(' . implode(', ', $args) . ')';
}
my_function('blah', 'blah', 'blah');
Output would be my_function(blah, blah, blah);
. Obviously this could be improved immensely to more accurately represent how the arguments were passed (ie. quoting the params that are output).
See func_get_args() man page for more information.