Re: included file var scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
>> In index.php rather than declaring vars like so...
>>
>> $var = 'value';
>>
>> ...declare them in the $GLOBALS array like so...
>>
>> $GLOBALS['var'] = 'value';
>>
>> $var is then in the global scope regardless of where it was set.
>>
>> -Stut
>>
>
> That would work. However I'm looking for a more generic solution,
> independent of the system that is being included. So basically I want to
> be able to include a file in my function while stepping out of the
> context of the function itself.
>
> E

put all those variables in a singleton.
then just use MyGlobals::getInstance()->myvar all over the place and you
can do whatever you want with them. of course don't forget to include the
class definition everywhere you want to use it

greets,
Zoltán Németh

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



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux