included_by() possible?
| From: | André Langhorst | Date: | Fri, 25 Aug 2000 07:26:41 +0000 |
| Subject: | included_by() possible? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-30591@lists.php.net to get a copy of this message | ||
I wonder if it *could* be possible to dertmine which file
included a file. If this is possible I´ll post a feature/request.
It´s a bit annoying that I´ll have to set a variable each time,
when I want the included file to know which is the include()ing file.
eg.
--- filea.php ---
include('fileb.php');
--- fileb.php ---
echo included_by(); // output 'fileb.php' or similar
CURRENTLY, it´s only possible this way
--- filea.php ---
$origin=__FILE__;
include('fileb.php');
--- fileb.php ---
echo $origin;
You´ll ask, why do you want to save this single line?
Well, for end-user satisfaction. If a user wants to user one
of my applications embedded in his own page, then it´d be best
if the user just had to do
<STUFF>aölsdkfaölsdkjf</STUFF>
<OTHER>aösldkfjalskdjfa</OTHER>
<?php include('my.application.php'); ?>
just like a nice component you plug into a page, no variables
no constants, no function calls, just a single include instruction.