php - is it possible check if given function is executing within other function or method? -


function echo_parent_func() {     echo // ? }  function somefunc() {     echo_parent_func(); }  somefunc(); //should echo string 'somefunc' 

is possible php ?

function get_caller_method()  {      $traces = debug_backtrace();       if (isset($traces[2]))      {          return $traces[2]['function'];      }       return null;  }   function echo_parent_func() {     echo get_caller_method(); }  function somefunc() {     echo_parent_func(); }  somefunc(); //should echo string 'somefunc' 

source

edit found this answer too:


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -