See debug_backtrace - this can trace your call stack all the way to the top.
Here's how you'd get your caller:
$trace = debug_backtrace();
$caller = $trace[1];
echo "Called by {$caller['function']}";
if (isset($caller['class']))
echo " in {$caller['class']}";
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…