RE: [PHP-DB] globals From: Dave VanAuken (dave <email protected>)
Date: 12/16/00

global just makes it available within the function, you then call the
variable as normal

using your code:

$j = 0;
function doThis($tempVariable) {
    global $myArray;
    if ($myArray[$j] == $tempVariable) {
        echo "whatever";
    }
    $j++;
}

-----Original Message-----
From: John Starkey [mailto:jstarkey <email protected>]
Sent: Saturday, December 16, 2000 10:56 AM
To: Dave VanAuken
Cc: php-db <email protected>
Subject: RE: [PHP-DB] globals

> $myArray;
> $myVariable;
> doThis($myVariable);
>
>
> function doThis($tempVariable) {
> global $myArray;
> # do whatever
> }

Then how wuld I declare the global as the condition of an if?

$j = 0;
function doThis($tempVariable) {
    if (global $myArray[$j] == $tempVariable) {
        echo "whatever";
    }
    $j++;
}

Thanks,

John

> -----Original Message-----
> From: John Starkey [mailto:jstarkey <email protected>]
> Sent: Saturday, December 16, 2000 3:19 AM
> To: php-db <email protected>
> Subject: [PHP-DB] globals
>
>
> Hello all.
>
> What are the rules for globals? I've seen them in tutorials but have had a
> hard time implementing them. I need to create an array outside of a
> function, pass a variable to that function, and then call the array for
> comparison to that variable. I can't pass the array to the function.
>
>
> Thanks,
>
> John
>
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>