With PHP include can you define the including page in the included page?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1074944/get-name-of-current-php-script-in-include-file">get name of current PHP script in include file</a><br>
  <a href="http://stackoverflow.com/questions/5204830/can-an-included-php-file-know-where-it-was-included-from">Can an included PHP file know where it was included from?</a>  </p>
</blockquote>



<p>Does that headline make sense? :)</p>

<p>Can you determine the <code>PHP</code> page that you put the <code>&lt;?php include 'SomeFile.php'; ?&gt;</code> into, FROM THE INCLUDED PAGE??</p>

<p>In the page to be '<code>INCLUDED</code>' have an if statement based on the destination that grabs it?</p>

<p>Am I even saying this right?</p>

<p>Thanks All!</p>

<h2>THE SOLUTION:</h2>

<h2>PAGEMAIN1.php</h2>

<pre><code>&lt;?php
$MAIN2 ='';
$MAIN1 = 'MAIN1';
include 'PAGE1.php';
include 'PAGE2.php';
include 'PAGE3.php';
include 'PAGE4.php';
?&gt;
</code></pre>

<h2>PAGEMAIN2.php</h2>

<pre><code>&lt;?php
$MAIN1 ='';
$MAIN2 = 'MAIN2';
include 'PAGE1.php';
include 'PAGE2.php';
include 'PAGE3.php';
include 'PAGE4.php';
?&gt;
</code></pre>

<h2>PAGE1.php</h2>

<pre><code>&lt;?php
$PAGE1 = 'PAGE1';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 1 being "INCLUDED" in MAIN 1)&lt;br&gt;';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 1 being "INCLUDED" in MAIN 2)&lt;br&gt;';
    }
?&gt;
</code></pre>

<h2>PAGE2.php</h2>

<pre><code>&lt;?php
$PAGE2 = 'PAGE2';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 2 being "INCLUDED" in MAIN 1)&lt;br&gt;';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 2 being "INCLUDED" in MAIN 2)&lt;br&gt;';
    }
?&gt;
</code></pre>

<h2>PAGE3.php</h2>

<pre><code>&lt;?php
$PAGE3 = 'PAGE3';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 3 being "INCLUDED" in MAIN 1)&lt;br&gt;';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 3 being "INCLUDED" in MAIN 2)&lt;br&gt;';
    }
?&gt;
</code></pre>

<h2>PAGE4.php</h2>

<pre><code>&lt;?php
$PAGE4 = 'PAGE4';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 4 being "INCLUDED" in MAIN 1)&lt;br&gt;';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 4 being "INCLUDED" in MAIN 2)&lt;br&gt;';
    }
?&gt;
</code></pre>

<h2>OUTPUT FROM PAGEMAIN1.php</h2>

<pre><code>(This is PAGE 1 being "INCLUDED" in MAIN 1)
(This is PAGE 2 being "INCLUDED" in MAIN 1)
(This is PAGE 3 being "INCLUDED" in MAIN 1)
(This is PAGE 4 being "INCLUDED" in MAIN 1)
</code></pre>

<h2>OUTPUT FROM PAGEMAIN2.php</h2>

<pre><code>(This is PAGE 1 being "INCLUDED" in MAIN 2)
(This is PAGE 2 being "INCLUDED" in MAIN 2)
(This is PAGE 3 being "INCLUDED" in MAIN 2)
(This is PAGE 4 being "INCLUDED" in MAIN 2)
</code></pre>

<p>Just in case you wanted to know. ;) Thanks!</p>
