Can an included PHP file know where it was included from?
<p>For example,</p>

<p>This is index.php</p>

<pre><code>&lt;?
require_once('header.php');
?&gt;
</code></pre>

<p>Can header.php know it was included by index.php?</p>

<p>--EDIT--</p>

<p>I found a solution:</p>

<pre><code>function backtrace_filename_includes($name){
    $backtrace_array=debug_backtrace();
    if (strpos($backtrace_array[1]['file'],$name)==false){
        return false;
    }else{
        return true;
    }
}
</code></pre>

<p>header.php</p>

<pre><code>&lt;?
if (backtrace_filename_includes('index.php')) echo "index.php";
?&gt;
</code></pre>
