note 60437 added to function.include
| From: | ajsharp at gmail dot com | Date: | Fri, 06 Jan 2006 21:20:34 +0000 |
| Subject: | note 60437 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101323@lists.php.net to get a copy of this message | ||
Does anyone know if PHP has a function to find out which script has included another, for example:
"a.php"
<?php
include './b.php';
?>
"b.php"
<?php
// function to find out what script included b.php
echo 'Hello world.';
?>
Such a function seems a bit pointless in such a simple script, but it could come in handy if one had
a sitewide variables script. You could use a switch or if statment to load specific variables, which
would be determined by which script included the variables page. For example:
"variables.php"
<?php
switch ($includer) {
case 'this_script.php':
$this_variable = 'hello john';
break;
case 'that_script.php':
$that_variable = 'hello jane';
break;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60437
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60437&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60437&report=yes
Search -- http://master.php.net/manage/user-notes.php