Re: help with PHP global array

From: Date: Thu, 07 Feb 2002 17:29:16 +0000
Subject: Re: help with PHP global array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83880@lists.php.net to get a copy of this message
On Thursday 07 February 2002 23:48, Wee Chua wrote: > Hi all, > I have tried: > global $myArray[] > > and it gives me an error 'the array expects semi-colon or comma'. Any helps > would be appreciated! > > Thanks, > Wee > > -----Original Message----- > From: Bjorn Abt [mailto:bjoern.abt@vertical.ch] > Sent: Thursday, February 07, 2002 10:57 AM > To: 'Chua@mail.interclean.com' > Subject: AW: [PHP] help with PHP global array > > > > I would try: > > global $myArray[] > > Greetings Björn > > -----Ursprüngliche Nachricht----- > Von: Wee Chua [ mailto:Chua@mail.interclean.com > <mailto:Chua@mail.interclean.com> ] > Gesendet: Donnerstag, 7. Februar 2002 16:35 > An: PHP (E-mail) > Betreff: [PHP] help with PHP global array > > > Hi all, > How can I declare a global array? Can I do this: > $global myArray[] > > would I find out it is an array when I use it in other places? > > Thanks, > Wee All variables in PHP are local to the scope in which it is defined. You cannot declare a variable as global (as such). To use a global variable: <? $doodah = 10; test_global(); function test_global() { global $doodah; echo("Doodah should be ten: $doodah"); } ?> See manual for details. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* A lot of people I know believe in positive thinking, and so do I. I believe everything positively stinks. -- Lew Col */

« previous php.general (#83880) next »