Re: Including files & variables ...
| From: | Tamas Arpad | Date: | Thu, 03 Jan 2002 09:26:45 +0000 |
| Subject: | Re: Including files & variables ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-79296@lists.php.net to get a copy of this message | ||
On Wednesday 02 January 2002 20:43, you wrote:
> What you need to do is simply set the variables before you include
> the script.
>
> When you include a script with include() or require(), they fall
> into the same namespace as the include() or require() function that
> called them.
I read that in the manual too, but I have never understoud how it
really works. I use require_once in function and the files I include
have many class and function definitions in it (I include them when I
really need them to make things faster). So when I try to imagine how
it works, I feel that it shouldn't.
Becuse if I put the files in place of the require_onces I would get a
code like this:
function foo() {
class foo2 {
function foo2() {
...
}
...
}
class foo3 { ... }
...
}
And it looks strange, but it works well, I use it frequently. Does
anybody know why is this code works actually?
Thanks,
Arpi
p.s. of course it's only a theoretical question. I don't have to
understand really, but it's good to know what I rely on.