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 #172503 is a reply to message #172484] Mon, 21 February 2011 13:07 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/21/2011 12:39 AM, Simon wrote:
>>
>> 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
>

No, files included in a function are NEVER accessible globally. They
are only available in the function - it's part of what functions do.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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:07:25 GMT 2024

Total time taken to generate the page: 0.04479 seconds