FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » require/include a file inside a function
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: require/include a file inside a function [message #172484 is a reply to message #172449] Mon, 21 February 2011 05:39 Go to previous messageGo to previous message
Simon is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Proxy to open blocked sites
Next Topic: problem with web service
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 15:23:45 GMT 2024

Total time taken to generate the page: 0.03527 seconds