Fw: [PHP] pass globals to functions???
| From: | Kevin Stone | Date: | Thu, 24 Oct 2002 20:06:55 +0000 |
| Subject: | Fw: [PHP] pass globals to functions??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-121347@lists.php.net to get a copy of this message | ||
Unless the variables need to be modified I'd say use constants which are
free from the limitations of variable scope.
http://www.php.net/manual/en/function.define.php
// example
define("SIZE", 100);
print_size();
function print_size(){
echo SIZE;
}
-Kevin
----- Original Message -----
From: "Shawn McKenzie" <nospam@mckenzies.net>
To: <php-general@lists.php.net>
Sent: Thursday, October 24, 2002 1:52 PM
Subject: [PHP] pass globals to functions???
> Some have eluded to this but I haven't seen a working example. I would
like
> to declare globals in my main script and then inside functions that need
> these globals just somehow use the $GLOBALS or something to declare the
> variables global in the function.
>
> What I've seen eluded to is loading your $GLOBALS array into an array...
>
> In short, if I add a variable to my globals line in my main script, I
don't
> want to have to go and add it to the functions that need it. Make
sense???
>
> TIA
> -Shawn
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>