Shawn McKenzie wrote:
> Robert Cummings wrote:
>> On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote:
>>> Robert Cummings wrote:
>>>> On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote:
>>>>> Sándor Tamás (HostWare Kft . ) wrote:
>>>>>> Yes, Rob is right. My original question is about the difference between
>>>>>> the processing of a file-based site with include() OR eval(). In that
>>>>>> case, if I understood it correctly, the results are the same.
>>>>>>
>>>>>> But! If the included pages contain functions, classes, etc. With eval(),
>>>>>> can I use them? With include(), I know I should be able to use them. But
>>>>>> in some mysterious cases I don't have access to a function. If I cut out
>>>>>> from the included file, and put in on the file which includes that, just
>>>>>> before (or after) the includ(), I don't have any problem with it.
>>>>>>
>>>>>> The next step, that if I include a file in a function, can I use the
>>>>>> functions wrote in the included file?
>>>>>> As I know, include just makes a copy-paste, so if I use it IN a
>>>>>> function, then all function will be in function scope, am I right?
>>>>> Yes, if you use an include inside a function, then any functions / non
>>>>> global vars in the included file will only be available inside the
>>>>> including function.
>>>> This is NOT, I repeat, NOT true for functions. Functions are ALWAYS
>>>> global.
>>>>
>>>> Cheers,
>>>> Rob.
>>> Yes, I was too hasty.  The nested function will only be defined once the
>>> nesting function has been called.  Then it will be available globally.
>> Actually, you're wrong again. The nested function, AKA function defined
>> in the included source, will be defined as soon as the source is
>> included and is available to the function in which the source was
>> included. In fact it is even available to the code within the included
>> source that can be run during the include process and before the
>> function performing the inclusion regains control.
>>
>> Cheers,
>> Rob.
> 
> Well I used the word defined, however what I meant was the included
> function would only be available globally after the including function
> has been called.  But yes, it will be available to the including function.
> 

Actually, which would mean that the including function had been called
if it was attempting to use any of the vars/functions in the included
file :-)

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to