Find out Where Function Was Called From in php

Recently had a problem where an API was getting called once mysteriously before it was supposed to be and discovered this little piece of useful code, which revealed that one of my class __construct()s was calling it.

$trace=debug_backtrace();
$caller=$trace[1];

echo "Called by {$caller['function']}";
if (isset($caller['class']))
    echo " in {$caller['class']}";