> 
> **Possible Duplicate:**  
> 
> [Caller function in PHP 5?](https://stackoverflow.com/questions/190421/caller-function-in-php-5) 
> 
> 
> 

I would like to know from where a global function or public method is being called. I guess I could do it by inspecting debug\_backtrace but I'd rather use a lighterweight mechanism if one exists. Any suggestions?

For example something like so, if you imagine the get\_callee() function and constant existing:

```
function doSomething() {
     if(get_callee() == 'PHP_GLOBAL') { throw new IllegalAccessException(); }
     ...
}

```