Re: [PHP4BETA]: require strategies
| From: | Teodor Cimpoesu | Date: | Thu, 18 Nov 1999 11:39:27 +0000 |
| Subject: | Re: [PHP4BETA]: require strategies | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-6438@lists.php.net to get a copy of this message | ||
Daniel Landau wrote:
>
> How do you folks deal with the following problem (if you ever do):
>
> FOO requires BAZ, and BAR requires BAZ, and FOO requires BAR. If both FOO
> and BAR include BAZ, then a function redefinition error occurs. If FOO is
> left responsible for including BAZ, and BAR is used independently of FOO
> (without being included by FOO) then FOO has not included BAZ, and an
> undefined function error occurs.
>
> It seems to me that require() should be responsible for tracking this kind
> of stuff, but it doesn't seem to be. Also, I though about writing a function
> to track repeated includes and not repeat, but including that function would
> subject to the same conundrum as above.
>
> Any ideas?
[BAZ]
<?if (!defined('_BAZ')){
define('_BAZ',1);
// content
}?>
[BAR]
<?if (!defined('_BAR')) {
define('_BAR',1);
if (!defined('_BAZ')) include 'BAZ';
//content
}?>
[FOO]
<? if(!defined('_FOO')) {
define('_FOO',1);
if (!defined('_BAR')) include 'BAR';
if (!defined('_BAZ')) include 'BAZ';
//content
}?>
that's all :)
--
CIMPOESU Teodor, Web Programmer
@ DIGICOM S.A. Bucharest, Romania
@ Internet, site development
@ teo@digiro.net , +(401)-330.47.28
official home page ~ http://www.digiro.net/
Internet web page ~ http://internet.digiro.net/