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:[EMAIL PROTECTED]]
> Sent: Thursday, February 07, 2002 10:57 AM
> To: '[EMAIL PROTECTED]'
> Subject: AW: [PHP] help with PHP global array
>
>
>
> I would try:
>
> global $myArray[]
>
> Greetings Björn
>
> -----Ursprüngliche Nachricht-----
> Von: Wee Chua [ mailto:[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> ]
> 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
*/

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

Reply via email to