Is there a way to get the name of the top level PHP file from inside an included one?
<p>Let's say I'm writing a global logData method that wants to write to a log file that has the same name as the php that's running it, but with a .log extension.</p>

<p>I'm including this logging in a parent php with the intention of having it always write to log files that are whatever the *parent file name is (not the tools.php lib in which it's sitting).</p>

<p>So, I have 
/some/arbitrary/directory/parent.php</p>

<p>which calls</p>

<p>include ("/path/to/my/php/libs/tools.php");</p>

<p>but when I run my logging method that's in tools.php it logs to a file called </p>

<p>/path/to/my/php/libs/tools.php.log</p>

<p>rather than 
/some/arbitrary/directory/parent.php.log  (which is what I'd like).</p>

<p>I'm using <code>__FILE__</code> which is behaving this way (probably as its intended to).  Is there a command for getting the parent's file name so that I can get this to work as I intend? Or will I have to pass <strong>FILE</strong> as a param into my method from the parent php to get it to write to the correct output file?</p>

<p>TIA</p>
