When using the PHP include, how can I find out which file is calling the include? In short, what is the parent\'s file filename?
I was searching same information on web for complement my online course about php and found two ways. The first was
$file = baseline($_SERVER['PHP_SELF']);
echo $file; //that outputs file name
BUT, in include or require cases it gets the final file that it's included or required. Also found this, the second
$file = __FILE__;
echo $file; //that outputs the absolute way from file
BUT i just was looking for the file name. So... I mix it up and it worths well!
$file = basename(__FILE__);
echo $file; //that outputs the file name itself (no include/require problems)