Created
May 13, 2015 14:46
-
-
Save Xatenev/43418a7e30969d324fd5 to your computer and use it in GitHub Desktop.
WhoIncludedThisFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whoIncludedThisFile() { | |
$bt = debug_backtrace(); | |
$includedMe = false; | |
while (count($bt) > 0) { | |
$set = array_shift($bt); | |
if ( | |
array_key_exists('function', $set) === true && | |
in_array($set['function'], array('require', 'require_once', 'include', 'include_once')) | |
){ | |
$includedMe = array('file'=>$set['file'], 'line'=>$set['line']); | |
break; | |
} | |
} | |
return $includedMe; | |
} | |
print_r(whoIncludedThisFile()); | |
// Array ( [file] => topLevelFile.php [line] => 2 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment