Re: isn't REQUIRE passed down to next REQUIRE?
| From: | Ignacio Vazquez-Abrams | Date: | Sun, 26 Nov 2000 03:43:02 +0000 |
| Subject: | Re: isn't REQUIRE passed down to next REQUIRE? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27220@lists.php.net to get a copy of this message | ||
On Sat, 25 Nov 2000, Derek Sivers wrote:
> IMAGINE THIS:
>
> <?
> /* INITIALIZE - set MySQL class, shopping cart class, and more... */
> require ("common_top.inc");
>
> if ($blah)
> {
> include ("some_content.php");
> }
>
> die ();
> ?>
>
>
> Now - shouldn't the "some_content.php" file be able to use things that were
> initialized in common_top.inc?
>
> It seems (through trial/error) that I have to re-initialize the stuff at
> the top of "some_content.php" again?!?
>
>
> Is this a bug? Is it supposed to be that way? Isn't it inefficient to
> call that stuff TWICE?
>
By any chance is the include()/require() inside a function? If so, then you
have a scope problem. Functions and definitions will be seen, but not
variables. You have to use global for use.
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>