Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    @Krzysztof Trzos Try echo $caller; and should work. ;-) Commented Feb 10, 2016 at 21:47
  • I confirm it is working for for php 5.6 Commented Feb 28, 2018 at 4:52
  • 7
    As of PHP 7 the 2nd line can be $caller = $dbt[1]['function'] ?? null; Commented Dec 19, 2019 at 21:59
  • Note that isset($something) ? $something : null can be shortened to $something ?? null in modern PHP versions. Edit: sorry, someone already covered this Commented May 15, 2020 at 4:32
  • or one line debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2)[1]['function'] ?? null; Commented Oct 14, 2020 at 13:59