// Get the __FILE__ constant for a function's caller in PHP
include "bar.php";
call_it();
//bar.php
function call_it() {
$bt = debug_backtrace();
echo "Calling file: ". $bt[0]['file'] . ' line '. $bt[0]['line'];
}
// http://stackoverflow.com/questions/1801928/get-the-file-constant-for-a-functions-caller-in-php