AW: [PHP-WIN] Functions and include files question?
| From: | (Sven Schnitzke) | Date: | Fri, 11 Apr 2003 09:50:49 +0000 |
| Subject: | AW: [PHP-WIN] Functions and include files question? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-19388@lists.php.net to get a copy of this message | ||
Including a file does not mean any more than textually
replace the include statement with the contents of the
file. An include file does not make up a scope of it's
own.
Btw: you can not transport any information from func to func
with your technique: the vars are named the same but the
locations differ.
So from the point of view of the functions they are no variables
but config/init constants or else they have to be declared global
anyway.
But if you use them for spreading init/config info you might want to
study the following:
http://www.php.net/manual/en/language.constants.php
--
Sven
> -----Ursprüngliche Nachricht-----
> Von: ODCS [SMTP:odcs@rogers.com]
> Gesendet am: Donnerstag, 10. April 2003 14:40
> An: Sven.Schnitzke@t-online.de
> Betreff: Re: [PHP-WIN] Functions and include files question?
>
> There has to be a better way than that - there are 20 separate variables in
> the file - before I would set them all global, I would just do what I am
> doing and re-include the file in each function. Is there not some option
> that can set the entire file as global?
>
>
> ----- Original Message -----
> From: "Sven Schnitzke" <Sven.Schnitzke@t-online.de>
> To: "'[PHP-WIN]'" <php-windows@lists.php.net>
> Sent: Thursday, April 10, 2003 4:12 AM
> Subject: AW: [PHP-WIN] Functions and include files question?
>
>
> PHPs scoping sceme is unusual in that it does not automatically
> show global variables in a function. Use
>
> global $var1, $var2;
>
> to make visible those global variables you need in the respective
> function.
>
> --
> Sven
>
> > -----Ursprüngliche Nachricht-----
> > Von: ODCS [SMTP:odcs@rogers.com]
> > Gesendet am: Donnerstag, 10. April 2003 07:06
> > An: PHP Windows
> > Betreff: [PHP-WIN] Functions and include files question?
> >
> > I have a file with 20 or so error messages in it which gets included at
> the
> > top of a script. How can I work this so the variables inside the included
> > file are available to the various functions in the script. Right now I am
> > just re-including it in every function - it works, but there has to be a
> > better way to do this. Is there a way I can make the whole file global?
> >
> > TIA.
> >
> >
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>