Re: switch-statement overrides use of global arrays?
| From: | Imar de Vries | Date: | Sun, 28 Oct 2001 21:49:02 +0000 |
| Subject: | Re: switch-statement overrides use of global arrays? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72642@lists.php.net to get a copy of this message | ||
Henrik Hudson wrote:
> I would think you would need to define $array_test outside in a "global"
> environment rather then inside the function since I think/thought it will
> just stay scoped in there and that "global" was used to access variables
> which weren't defined inside a functions scope and make it look outside.
>
> In other words
>
> //Define GLOBAL
> $array_test = array();
>
> switch(){
> BLAH
> BLAH
>
> }
>
> function main() {
> global $array_test;
> BLAH
> BLAH
>
> }
>
> function test_one(){
> global $array_test;
> BLAH
> BLAH
>
> }
Yes, the only way I could avoid errors that occurred when I tried to manipulate
the array, was to add a $array_test = array(); a few lines before the switch
statement. Alas, this also emptied the array each time I went from one function
to another via the switch statement.
I guess I am trying something that is just not possible (when I insist on using
the switch statement)?
--
Imar de Vries - I.O.deVries@students.let.uu.nl - ICQ 6972439