Re: Include Files self aware?
| From: | Billy S Halsey | Date: | Tue, 30 Apr 2002 23:52:57 +0000 |
| Subject: | Re: Include Files self aware? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95454@lists.php.net to get a copy of this message | ||
Try this code (untested):
function selfAwareInclude($filename)
{
define($filename, true);
include($filename);
}
Inside your include file, make calls such as
if (defined($filename)) {
// Do whatever
}
Then use the selfAwareInclude() function instead of include(). You could do the same with require, etc.
/bsh/
PHP List wrote:
Hi,
Is it possible to detect if a file is being called as an include or require?
ex:
include("file.php") <-- file.php code can "detect" that is has been
called as an include.
Thanks,
Chris
--
/---------------------------------------------=[ BILLY S HALSEY ]=--\
| Member of Technical Staff, Sun Microsystems, Inc. ESP Solaris SW |
| "All opinions and technical advice offered in this message are my |
| own and not necessarily endorsed by my employer." |
\--=[ bsh-php@sun.com ]=--------------------------------------------/