Fw: [PHP] Friend of function??
| From: | Kevin Stone | Date: | Wed, 18 Sep 2002 22:18:40 +0000 |
| Subject: | Fw: [PHP] Friend of function?? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-116802@lists.php.net to get a copy of this message | ||
I don't think there is a way to do pull a variable into the local scope of a
function without passing it as a value to the function. But you can always
do this..
myfunction() {
global $myarray;
//..use myarray..//
unset $GLOBALS['myarray'];
}
You're in no danger this way.
-Kevin
----- Original Message -----
From: "Anup" <anup_patel@rogers.com>
To: <php-general@lists.php.net>
Sent: Wednesday, September 18, 2002 3:54 PM
Subject: [PHP] Friend of function??
> I want to use arrays (that are outside of a function) to be visible to a
> function. I understand that I must you global. But I was wondering is it
> possible to make it visible to only certain functions, similar to the
> 'friend' keyword in C (or C++ ?) ? The reason, is that I don't feel
> comfortable having globals, (I was brought up that way). Also, if you
> actually declare something global are there any disadvantages such as
> performance hits?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>