Re: knowing which file is including

From: Date: Sat, 27 Mar 2004 05:18:28 +0000
Subject: Re: knowing which file is including
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181604@lists.php.net to get a copy of this message
ryan@coinpass.com (Ryan A) wrote in news:000301c413a6$8f5c8280$f081aa51@l2zcaxu7emppqh: > Hi, > A bit of a weird problem, am just curious if this can be done... > > I have a file called config.inc.php which has a require_once in it for > lang_a.php and > lang_b.php > > config.inc.php is being "included" by a.php and b.php > > presently config.inc.php is doing a require_once for both lang_a and > lang_b, is there any way to determine > which file is calling the config.inc.php (a or b) and then set the > require accordingly? I dont think so but am > just wondering as PHP has a crapload of solutions that I would > probably never know of. > > Thanks, > -Ryan > Maybe you could check for the existence of a value which is set uniquely according to whether it is in lang_a or lang_b; set the value before the include then test in the included file to determine the action to be taken. There are a couple of functions, get_included_files and get_required_files which might have some use to you - if not here, for future reference.

« previous php.general (#181604) next »