The simplest way is:
echo debug_backtrace()[1]['function'];
As noted in the comments below, this can be further optimized by passing arguments to:
- omit both the
object
andargs
indices - limit the number of stack frames returned
echo debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT|DEBUG_BACKTRACE_IGNORE_ARGS,2)[1]['function'];