Re: require/include a file inside a function [message #172484 is a reply to message #172449] |
Mon, 21 February 2011 05:39 |
Simon
Messages: 29 Registered: February 2011
Karma:
|
Junior Member |
|
|
>
> If you try it you will find that included code is included at the
> point where the include is written. So if that it in a function, that
> will be where the code is.
Not sure I follow,
If I have something like
function fn_b()
{
include (a_big_file.php);
}
function fn_a()
{
fn_b();
// stuff, (functions, classes), created in fn_b() are not available
// to me here anymore.
// I am using 5.2.14 (dev) and 5.3.2 (live), (don't even ask me why!).
}
>
> Take a look at the php magic function autoload:
> http://www.phpro.org/tutorials/SPL-Autoload.html
Yes, this looks like it might actually help.
I will try, (I only got to work now), and see if files included in a
function that create a class still make the class globally available.
Simon
|
|
|