February 12, 2014

PHP Helper Function: get_function_static()

PHP Helper Function: get_function_static()

Description: This function returns the name of calling function. You can specify the $index param to retrieve nth level of calling functions.
function get_function_static($bt, $index=0) {
if (isset($bt[$index]['function']))
return $bt[$index]['function'];
else
return false;
}

Usage

$bt = debug_backtrace();
$parent_function = $this->get_function_static($bt, 1);

Last updated: March 19, 2014