In article <9e6s21$2rk$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Richard") wrote:

> So i should start the header (or wherever in the header) with :
> 
>     $GLOBALS["userPassword"] = "whatever";
> 
>     function cp() {
>         global $userPassword;
> 
>         // $userPassword is 'whatever' //
>     }

You're making an extra step.  The variables stored in the $GLOBALS array 
don't have to be declared as global within a function.  They're already 
available within the function.  To make a global variable available within 
a function's local namespace, you _either_:

* pass it by reference: function cp(&$userPassword)
* declare it as a global: global $userPassword
* make it an element of the $GLOBALS array: $GLOBALS['userPassword']

(You could also pass by value, but then you're dealing with a copy of the 
variable instead of the variable itself.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to