note 60885 deleted from function.include by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 18:23:15 +0000 |
| Subject: | note 60885 deleted from function.include by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133275@lists.php.net to get a copy of this message | ||
Note Submitter: Stephen Lee
----
@ajsharp at gmail dot com
To find out which script has included another, use the Server Variable 'SCRIPT_NAME'
(note: there are other server variables that also contain the script name, but I use this one simply
because it works for me) e.g.
"variables.php"
<?php
$includer = basename($_SERVER['SCRIPT_NAME']);
switch ($includer) {
case 'a.php':
$this_variable = 'included by script a.php';
break;
case 'b.php':
$this_variable = 'included by script b.php';
break;
default:
$this_variable = 'included by unkown script';
}
echo $this_variable;
?>
Test with 3 different files "a.php", "b.php", "c.php", all with the
same content:
<?php
include 'variables.php';
?>